1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-11-17 06:45:05 -05:00

Fixes issues when using system default for Date format, it will now properly display it in your locale.

This commit is contained in:
echel0n 2014-05-17 00:56:41 -07:00
parent 58e0b58a0f
commit 9a23bfd0f5

View File

@ -94,13 +94,14 @@ class static_or_instance(object):
# subclass datetime.datetime to add function to display custom date and time formats # subclass datetime.datetime to add function to display custom date and time formats
class sbdatetime(datetime.datetime): class sbdatetime(datetime.datetime):
has_locale = True has_locale = True
ORIG_LC_TIME = locale.LC_TIME
# display Time in Sickbeard Format # display Time in Sickbeard Format
@static_or_instance @static_or_instance
def sbftime(self, dt=None, show_seconds=False, t_preset=None): def sbftime(self, dt=None, show_seconds=False, t_preset=None):
try: try:
locale.setlocale(locale.LC_TIME, '') locale.setlocale(locale.LC_TIME, self.ORIG_LC_TIME)
except: except:
pass pass
@ -129,7 +130,7 @@ class sbdatetime(datetime.datetime):
finally: finally:
try: try:
if sbdatetime.has_locale: if sbdatetime.has_locale:
locale.setlocale(locale.LC_TIME, '') locale.setlocale(locale.LC_TIME, self.ORIG_LC_TIME)
except: except:
sbdatetime.has_locale = False sbdatetime.has_locale = False
return strt return strt
@ -139,7 +140,7 @@ class sbdatetime(datetime.datetime):
def sbfdate(self, dt=None, d_preset=None): def sbfdate(self, dt=None, d_preset=None):
try: try:
locale.setlocale(locale.LC_TIME, '') locale.setlocale(locale.LC_TIME, self.ORIG_LC_TIME)
except: except:
pass pass
@ -164,7 +165,7 @@ class sbdatetime(datetime.datetime):
def sbfdatetime(self, dt=None, show_seconds=False, d_preset=None, t_preset=None): def sbfdatetime(self, dt=None, show_seconds=False, d_preset=None, t_preset=None):
try: try:
locale.setlocale(locale.LC_TIME, '') locale.setlocale(locale.LC_TIME, self.ORIG_LC_TIME)
except: except:
pass pass
@ -206,7 +207,7 @@ class sbdatetime(datetime.datetime):
finally: finally:
try: try:
if sbdatetime.has_locale: if sbdatetime.has_locale:
locale.setlocale(locale.LC_TIME, '') locale.setlocale(locale.LC_TIME, self.ORIG_LC_TIME)
except: except:
sbdatetime.has_locale = False sbdatetime.has_locale = False
return strd return strd