mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Workaround for local timezones with historical dates on crippled commercial operating systems
This commit is contained in:
parent
2a4d6d938e
commit
ee43ccb71e
@ -11,8 +11,17 @@ from datetime import datetime
|
|||||||
from dateutil.parser import parse
|
from dateutil.parser import parse
|
||||||
from dateutil.tz import tzlocal, tzutc
|
from dateutil.tz import tzlocal, tzutc
|
||||||
|
|
||||||
|
class SafeLocalTimeZone(tzlocal):
|
||||||
|
|
||||||
|
def _isdst(self, dt):
|
||||||
|
try:
|
||||||
|
return tzlocal._isdst(self, dt)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
return False
|
||||||
|
|
||||||
utc_tz = _utc_tz = tzutc()
|
utc_tz = _utc_tz = tzutc()
|
||||||
local_tz = _local_tz = tzlocal()
|
local_tz = _local_tz = SafeLocalTimeZone()
|
||||||
|
|
||||||
def parse_date(date_string, assume_utc=False, as_utc=True, default=None):
|
def parse_date(date_string, assume_utc=False, as_utc=True, default=None):
|
||||||
'''
|
'''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user