mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-03 01:43:37 +00:00
Merge pull request #801 from JackDandy/feature/ChangeFallbackNoneTimezone
Feature/change fallback none timezone
This commit is contained in:
commit
ade7ebb367
6 changed files with 575 additions and 65 deletions
|
@ -16,6 +16,7 @@
|
|||
* Update Hachoir library 1.3.4 (r1383) to 1.3.4 (r1435)
|
||||
* Update html5lib 0.999 to 0.99999999/1.0b9 (46dae3d)
|
||||
* Update IMDb 5.0 to 5.1dev20160106
|
||||
* Update moment.js 2.6 to 2.15.1
|
||||
* Update PNotify library 2.0.1 to 2.1.0
|
||||
* Update profilehooks 1.4 to 1.8.2.dev0 (ee3f1a8)
|
||||
* Update Requests library 2.7.0 (5d6d1bc) to 2.9.1 (a1c9b84)
|
||||
|
@ -181,6 +182,8 @@
|
|||
* Change hachoir_parser to close input stream if no parser is found e.g. due to file corruption
|
||||
* Change reduce time taken to parse avi RIFF metadata during post processing and other times
|
||||
* Change avi metadata extraction is more fault tolerant and the chance of hanging due to corrupt avi files is reduced
|
||||
* Change fuzzyMoment to handle air dates before ~1970 on display show page
|
||||
* Change limit availability of fuzzy date functions on General Config/Interface to English locale systems
|
||||
|
||||
[develop changelog]
|
||||
* Change send nzb data to NZBGet for Anizb instead of url
|
||||
|
@ -205,6 +208,7 @@
|
|||
* Change add helper function to validate acceptable image file extension
|
||||
* Change make sure avi files are closed if an error occurs
|
||||
* Change refactor hachoir scan_index for non RIFF file processing
|
||||
* Change ensure sbdatetime functions return formatted string instead of tuple
|
||||
|
||||
|
||||
### 0.11.16 (2016-10-16 17:30:00 UTC)
|
||||
|
|
|
@ -332,6 +332,10 @@
|
|||
</label>
|
||||
</div>
|
||||
|
||||
#if not $sbdatetime.is_locale_eng()
|
||||
<input type="hidden" name="fuzzy_dating" id="fuzzy_dating" value="false">
|
||||
<input type="hidden" name="trim_zero" id="trim_zero" value="false">
|
||||
#else
|
||||
<div class="field-pair">
|
||||
<label for="fuzzy_dating">
|
||||
<span class="component-title">Display fuzzy dates</span>
|
||||
|
@ -350,7 +354,7 @@
|
|||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
#end if
|
||||
<div class="field-pair">
|
||||
<label for="date_presets">
|
||||
<span class="component-title">Date style:</span>
|
||||
|
|
|
@ -548,7 +548,7 @@
|
|||
</td>
|
||||
|
||||
<td class="col-airdate">
|
||||
<span class="${fuzzydate}">#if 1 == int($epResult['airdate']) then 'never' else $sbdatetime.sbdatetime.sbfdate($sbdatetime.sbdatetime.convert_to_setting($network_timezones.parse_date_time($epResult['airdate'], $network_time, $network_timezone)))#</span>
|
||||
<span class="${fuzzydate}"#if $sickbeard.FUZZY_DATING# data-fulldate="$sbdatetime.sbdatetime.sbfdate(dt=$datetime.date.fromordinal($epResult['airdate']), d_preset='%A, %B %d, %Y')"#end if#>#if 1 == int($epResult['airdate']) then 'never' else $sbdatetime.sbdatetime.sbfdate($sbdatetime.sbdatetime.convert_to_setting($network_timezones.parse_date_time($epResult['airdate'], $network_time, $network_timezone)))#</span>
|
||||
</td>
|
||||
|
||||
#if $sickbeard.USE_SUBTITLES and $show.subtitles
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
dtInline = (/undefined/i.test(typeof(fmConfig)) || /undefined/i.test(typeof(fmConfig.dtInline)) ? false : fmConfig.dtInline),
|
||||
|
||||
jd = (function (str) {
|
||||
var token_map = ['a', 'ddd', 'A', 'dddd', 'b', 'MMM', 'B', 'MMMM', 'd', 'DD', 'm', 'MM', 'y', 'YY', 'Y', 'YYYY', 'x', 'L',
|
||||
var token_map = ['d', 'DD', 'a', 'ddd', 'A', 'dddd', 'b', 'MMM', 'B', 'MMMM', 'm', 'MM', 'y', 'YY', 'Y', 'YYYY', 'x', 'L',
|
||||
'H', 'HH', 'I', 'hh', 'M', 'mm', 'S', 'ss', 'p', 'A', 'P', 'a'],
|
||||
result = '';
|
||||
|
||||
|
@ -36,8 +36,6 @@
|
|||
|
||||
return result;
|
||||
}),
|
||||
dateTemplate = jd(dateFormat),
|
||||
timeTemplate = jd(timeFormat),
|
||||
|
||||
addQTip = (function() {
|
||||
$(this).css('cursor', 'help');
|
||||
|
@ -48,10 +46,7 @@
|
|||
position: {
|
||||
viewport: $(window),
|
||||
my: 'left center',
|
||||
adjust: {
|
||||
y: -10,
|
||||
x: 2
|
||||
}
|
||||
adjust: { y: -10, x: 2 }
|
||||
},
|
||||
style: {
|
||||
classes: 'qtip-dark qtip-rounded qtip-shadow'
|
||||
|
@ -59,18 +54,18 @@
|
|||
});
|
||||
});
|
||||
|
||||
if (trimZero) {
|
||||
timeTemplate = timeTemplate.replace(/hh/g, 'h');
|
||||
timeTemplate = timeTemplate.replace(/HH/g, 'H');
|
||||
dateTemplate = dateTemplate.replace(/\bDD\b/g, 'D');
|
||||
}
|
||||
|
||||
$(containerClass).each(function() {
|
||||
var input = $(this).text(),
|
||||
var attrFullDate = $(this).data('fulldate'),
|
||||
useTextDate = /undefined/i.test(typeof(attrFullDate)),
|
||||
input = useTextDate ? $(this).text() : attrFullDate,
|
||||
inputDateTemplate = jd(useTextDate ? dateFormat : '%A, %B %d, %Y'),
|
||||
inDateTemplate = trimZero ? inputDateTemplate.replace(/\bDD\b/g, 'D') : inputDateTemplate,
|
||||
outDateTemplate = trimZero ? jd(dateFormat).replace(/\bDD\b/g, 'D') : jd(dateFormat),
|
||||
timeTemplate = trimZero ? jd(timeFormat).replace(/hh/g, 'h').replace(/HH/g, 'H') : jd(timeFormat),
|
||||
timeToken = timeTemplate,
|
||||
dateA = '[<span class="fd">',
|
||||
dtSeparator = ' ',
|
||||
timeA = '</span>]', timeB = '[' + timeA,
|
||||
timeToken = timeTemplate;
|
||||
timeA = '</span>]', timeB = '[' + timeA;
|
||||
|
||||
if (dateWithTime) {
|
||||
var timeMeta = input.match(/([,\s]+)(\d{1,2})(?:(.)(\d\d)(?:(.)(\d\d))?)?(?:\s?([ap]m))?$/im);
|
||||
|
@ -103,12 +98,13 @@
|
|||
timeB = '[</span>' + dtGlue + '<span class="ft">]' + timeToken + timeB;
|
||||
}
|
||||
|
||||
var inputTokens = dateTemplate + dtSeparator + (dateWithTime ? timeToken : 'HH:mm:ss');
|
||||
var inputTokens = inDateTemplate + dtSeparator + (dateWithTime ? timeToken : 'HH:mm:ss'),
|
||||
outTokens = outDateTemplate + dtSeparator + (dateWithTime ? timeToken : 'HH:mm:ss');
|
||||
|
||||
if (! moment(input + (dateWithTime ? '' : dtSeparator + '00:00:00'), inputTokens).isValid())
|
||||
if (! (moment(input + (dateWithTime ? '' : dtSeparator + '00:00:00'), inputTokens).isValid()
|
||||
&& moment(input + (dateWithTime ? '' : dtSeparator + '00:00:00'), outTokens).isValid()))
|
||||
return;
|
||||
|
||||
moment.lang('en', {
|
||||
moment.updateLocale('en', {
|
||||
calendar: {
|
||||
lastDay:dateA + 'Yesterday' + timeA, sameDay:dateA + 'Today' + timeA, nextDay:dateA + 'Tomorrow' + timeA,
|
||||
lastWeek:dateA + 'last] ddd' + timeB, nextWeek:dateA + 'on] ddd' + timeB,
|
||||
|
@ -155,7 +151,7 @@
|
|||
titleThis = true;
|
||||
}
|
||||
|
||||
var n = false; // disable for prod
|
||||
var n = !1; // disable for prod
|
||||
$(this).html(result);
|
||||
if (dateWithTime && /(yester|to)day/i.test(result))
|
||||
$(this).find('.fd').attr('title',(n?'1) ':'') + moment.duration(airdatetime.diff(moment(),'seconds'),'seconds').humanize(true)).each(addQTip);
|
||||
|
@ -168,13 +164,13 @@
|
|||
|
||||
if (titleThis)
|
||||
if (dateWithTime && qTipTime)
|
||||
$(this).attr('title',(n?'4) ':'') + airdatetime.format(inputTokens)).each(addQTip);
|
||||
$(this).attr('title',(n?'4) ':'') + airdatetime.format(outTokens)).each(addQTip);
|
||||
else
|
||||
$(this).attr('title',(n?'5) ':'') + airdate.format(dateTemplate)).each(addQTip);
|
||||
$(this).attr('title',(n?'5) ':'') + airdate.format(outDateTemplate)).each(addQTip);
|
||||
else
|
||||
if (dateWithTime && qTipTime)
|
||||
$(this).find('.ft').attr('title',(n?'6) ':'') + airdatetime.format(inputTokens)).each(addQTip);
|
||||
$(this).find('.ft').attr('title',(n?'6) ':'') + airdatetime.format(outTokens)).each(addQTip);
|
||||
else
|
||||
$(this).find('.ft').attr('title',(n?'7) ':'') + airdate.format(dateTemplate)).each(addQTip);
|
||||
$(this).find('.ft').attr('title',(n?'7) ':'') + airdate.format(outDateTemplate)).each(addQTip);
|
||||
});
|
||||
}
|
||||
|
|
493
gui/slick/js/moment/moment.min.js
vendored
493
gui/slick/js/moment/moment.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -104,13 +104,21 @@ class static_or_instance(object):
|
|||
class sbdatetime(datetime.datetime):
|
||||
has_locale = True
|
||||
|
||||
@static_or_instance
|
||||
def is_locale_eng(self):
|
||||
today = sbdatetime.sbfdate(sbdatetime.now(), '%A').lower()
|
||||
return ('day' == today[-3::] and today[0:-3:] in ['sun', 'mon', 'tues', 'wednes', 'thurs', 'fri', 'satur']
|
||||
and sbdatetime.sbfdate(sbdatetime.now(), '%B').lower() in [
|
||||
'january', 'february', 'march', 'april', 'may', 'june',
|
||||
'july', 'august', 'september', 'october', 'november', 'december'])
|
||||
|
||||
@static_or_instance
|
||||
def convert_to_setting(self, dt=None):
|
||||
obj = (dt, self)[self is not None]
|
||||
try:
|
||||
if 'local' == sickbeard.TIMEZONE_DISPLAY:
|
||||
return obj.astimezone(sb_timezone)
|
||||
except:
|
||||
except (StandardError, Exception):
|
||||
pass
|
||||
|
||||
return obj
|
||||
|
@ -121,7 +129,7 @@ class sbdatetime(datetime.datetime):
|
|||
try:
|
||||
if None is use_has_locale or use_has_locale:
|
||||
locale.setlocale(locale.LC_TIME, locale_str)
|
||||
except:
|
||||
except locale.Error:
|
||||
if None is not use_has_locale:
|
||||
sbdatetime.has_locale = False
|
||||
pass
|
||||
|
@ -133,41 +141,40 @@ class sbdatetime(datetime.datetime):
|
|||
sbdatetime.setlocale(setlocale=setlocale, use_has_locale=sbdatetime.has_locale, locale_str='us_US')
|
||||
|
||||
strt = ''
|
||||
try:
|
||||
obj = (dt, self)[self is not None]
|
||||
if None is not obj:
|
||||
tmpl = (((sickbeard.TIME_PRESET, sickbeard.TIME_PRESET_W_SECONDS)[show_seconds]),
|
||||
t_preset)[None is not t_preset]
|
||||
tmpl = (tmpl.replace(':%S', ''), tmpl)[show_seconds]
|
||||
|
||||
strt = obj.strftime(tmpl.replace('%P', '%p'))
|
||||
obj = (dt, self)[self is not None]
|
||||
if None is not obj:
|
||||
tmpl = (((sickbeard.TIME_PRESET, sickbeard.TIME_PRESET_W_SECONDS)[show_seconds]),
|
||||
t_preset)[None is not t_preset]
|
||||
tmpl = (tmpl.replace(':%S', ''), tmpl)[show_seconds]
|
||||
|
||||
strt = sbdatetime.sbstrftime(obj, tmpl.replace('%P', '%p'))
|
||||
|
||||
if sickbeard.TRIM_ZERO:
|
||||
strt = re.sub(r'^0(\d:\d\d)', r'\1', strt)
|
||||
|
||||
if re.search(r'(?im)%p$', tmpl):
|
||||
if '%p' in tmpl:
|
||||
strt = strt.upper()
|
||||
elif '%P' in tmpl:
|
||||
strt = strt.lower()
|
||||
|
||||
if sickbeard.TRIM_ZERO:
|
||||
strt = re.sub(r'^0(\d:\d\d)', r'\1', strt)
|
||||
strt = re.sub(r'(?im)^(\d+)(?::00)?(\s?[ap]m)', r'\1\2', strt)
|
||||
|
||||
if re.search(r'(?im)%p$', tmpl):
|
||||
if '%p' in tmpl:
|
||||
strt = strt.upper()
|
||||
elif '%P' in tmpl:
|
||||
strt = strt.lower()
|
||||
if markup:
|
||||
match = re.search(r'(?im)(\d{1,2})(?:(.)(\d\d)(?:(.)(\d\d))?)?(?:\s?([ap]m))?$', strt)
|
||||
if match:
|
||||
strt = ('%s%s%s%s%s%s' % (
|
||||
('<span class="time-hr">%s</span>' % match.group(1), '')[None is match.group(1)],
|
||||
('<span class="time-hr-min">%s</span>' % match.group(2), '')[None is match.group(2)],
|
||||
('<span class="time-min">%s</span>' % match.group(3), '')[None is match.group(3)],
|
||||
('<span class="time-min-sec">%s</span>' % match.group(4), '')[None is match.group(4)],
|
||||
('<span class="time-sec">%s</span>' % match.group(5), '')[None is match.group(5)],
|
||||
('<span class="time-am-pm">%s</span>' % match.group(6), '')[None is match.group(6)]))
|
||||
|
||||
if sickbeard.TRIM_ZERO:
|
||||
strt = re.sub(r'(?im)^(\d+)(?::00)?(\s?[ap]m)', r'\1\2', strt)
|
||||
|
||||
if markup:
|
||||
match = re.search(r'(?im)(\d{1,2})(?:(.)(\d\d)(?:(.)(\d\d))?)?(?:\s?([ap]m))?$', strt)
|
||||
if match:
|
||||
strt = ('%s%s%s%s%s%s' % (
|
||||
('<span class="time-hr">%s</span>' % match.group(1), '')[None is match.group(1)],
|
||||
('<span class="time-hr-min">%s</span>' % match.group(2), '')[None is match.group(2)],
|
||||
('<span class="time-min">%s</span>' % match.group(3), '')[None is match.group(3)],
|
||||
('<span class="time-min-sec">%s</span>' % match.group(4), '')[None is match.group(4)],
|
||||
('<span class="time-sec">%s</span>' % match.group(5), '')[None is match.group(5)],
|
||||
('<span class="time-am-pm">%s</span>' % match.group(6), '')[None is match.group(6)]))
|
||||
|
||||
finally:
|
||||
sbdatetime.setlocale(setlocale=setlocale, use_has_locale=sbdatetime.has_locale)
|
||||
return strt
|
||||
sbdatetime.setlocale(setlocale=setlocale, use_has_locale=sbdatetime.has_locale)
|
||||
return strt
|
||||
|
||||
# display Date in SickGear Format
|
||||
@static_or_instance
|
||||
|
@ -179,7 +186,7 @@ class sbdatetime(datetime.datetime):
|
|||
try:
|
||||
obj = (dt, self)[self is not None]
|
||||
if None is not obj:
|
||||
strd = obj.strftime((sickbeard.DATE_PRESET, d_preset)[None is not d_preset])
|
||||
strd = sbdatetime.sbstrftime(obj, (sickbeard.DATE_PRESET, d_preset)[None is not d_preset])
|
||||
|
||||
finally:
|
||||
sbdatetime.setlocale(setlocale=setlocale)
|
||||
|
@ -195,13 +202,23 @@ class sbdatetime(datetime.datetime):
|
|||
obj = (dt, self)[self is not None]
|
||||
try:
|
||||
if None is not obj:
|
||||
strd = u'%s, %s' % (obj.strftime((sickbeard.DATE_PRESET, d_preset)[None is not d_preset]),
|
||||
sbdatetime.sbftime(dt, show_seconds, t_preset, False, markup))
|
||||
strd = u'%s, %s' % (
|
||||
sbdatetime.sbstrftime(obj, (sickbeard.DATE_PRESET, d_preset)[None is not d_preset]),
|
||||
sbdatetime.sbftime(dt, show_seconds, t_preset, False, markup))
|
||||
|
||||
finally:
|
||||
sbdatetime.setlocale(use_has_locale=sbdatetime.has_locale)
|
||||
return strd
|
||||
|
||||
@staticmethod
|
||||
def sbstrftime(obj, str_format):
|
||||
try:
|
||||
result = obj.strftime(str_format),
|
||||
except ValueError:
|
||||
result = obj.replace(tzinfo=None).strftime(str_format)
|
||||
return result if isinstance(result, basestring) else \
|
||||
isinstance(result, tuple) and 1 == len(result) and '%s' % result[0] or ''
|
||||
|
||||
@static_or_instance
|
||||
def totimestamp(self, dt=None, default=None):
|
||||
obj = (dt, self)[self is not None]
|
||||
|
@ -209,4 +226,4 @@ class sbdatetime(datetime.datetime):
|
|||
try:
|
||||
timestamp = time.mktime(obj.timetuple())
|
||||
finally:
|
||||
return (default, timestamp)[isinstance(timestamp, float)]
|
||||
return (default, timestamp)[isinstance(timestamp, float)]
|
||||
|
|
Loading…
Reference in a new issue