Try to use native time zone of Windows
The dateutil implementation fails on Windows for date before epoch. issue8145 review58541002
This commit is contained in:
1 parent
016c531971
commit
0fb0609697
2 files changed
+9
-14
No files matched your search
@@ -431,11 +431,6 @@ increases if lower case or decreases if upper case:
|
||||
- `i`: by one minute
|
||||
- `s`: by one second
|
||||
|
||||
.. warn::
|
||||
Under Windows, the datetime before 1970 are shown in UTC instead of the
|
||||
local timezone.
|
||||
..
|
||||
|
||||
Search Widget
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ try:
|
||||
except ImportError:
|
||||
ssl = None
|
||||
from threading import Lock
|
||||
import dateutil.tz
|
||||
|
||||
from gi.repository import Gdk, GdkPixbuf, GLib, GObject, Gtk
|
||||
|
||||
@@ -1243,16 +1242,17 @@ def filter_domain(domain):
|
||||
|
||||
|
||||
def timezoned_date(date, reverse=False):
|
||||
lzone = dateutil.tz.tzlocal()
|
||||
szone = dateutil.tz.tzutc()
|
||||
try:
|
||||
from dateutil.tz.win import tzwinlocal as tzlocal
|
||||
except ImportError:
|
||||
from dateutil.tz import tzlocal
|
||||
from dateutil.tz import tzutc
|
||||
|
||||
lzone = tzlocal()
|
||||
szone = tzutc()
|
||||
if reverse:
|
||||
lzone, szone = szone, lzone
|
||||
try:
|
||||
return (date.replace(tzinfo=szone).astimezone(lzone)
|
||||
.replace(tzinfo=None))
|
||||
except (ValueError, OSError):
|
||||
# https://github.com/dateutil/dateutil/issues/434
|
||||
return date.replace(tzinfo=None)
|
||||
return date.replace(tzinfo=szone).astimezone(lzone).replace(tzinfo=None)
|
||||
|
||||
|
||||
def untimezoned_date(date):
|
||||
|
||||
Reference in new issue
Block a user