mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Fix a regression in the previous release that broke parsing of some IS0 8601 timestamps. Fixes #2031341 [Calibre corrupts last modified date when using the server](https://bugs.launchpad.net/calibre/+bug/2031341)
timezone() unlike tzoffset() requires timedelta() objects instead of seconds
This commit is contained in:
parent
d26bc9fb45
commit
c68ba38533
@ -2,11 +2,10 @@
|
||||
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
from datetime import datetime, timezone
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from calibre_extensions import speedup
|
||||
|
||||
|
||||
utc_tz = timezone.utc
|
||||
local_tz = datetime.now().astimezone().tzinfo
|
||||
UNDEFINED_DATE = datetime(101,1,1, tzinfo=utc_tz)
|
||||
@ -23,7 +22,7 @@ def parse_iso8601(date_string, assume_utc=False, as_utc=True, require_aware=Fals
|
||||
else:
|
||||
sign = '-' if tzseconds < 0 else '+'
|
||||
description = "%s%02d:%02d" % (sign, abs(tzseconds) // 3600, (abs(tzseconds) % 3600) // 60)
|
||||
tz = timezone(tzseconds, description)
|
||||
tz = timezone(timedelta(seconds=tzseconds), description)
|
||||
elif require_aware:
|
||||
raise ValueError(f'{date_string} does not specify a time zone')
|
||||
dt = dt.replace(tzinfo=tz)
|
||||
|
Loading…
x
Reference in New Issue
Block a user