Downgrade tzlocal-2.1

This commit is contained in:
JonnyWong16 2021-10-15 09:05:54 -07:00
parent 5d46655507
commit ea398827cb
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
4 changed files with 33 additions and 46 deletions

View file

@ -1,18 +1,13 @@
import sys
try:
import _winreg as winreg
except ImportError:
import winreg
import pytz
from tzlocal.windows_tz import win_tz
from tzlocal import utils
if sys.version_info >= (3, 9):
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
else:
from backports.zoneinfo import ZoneInfo, ZoneInfoNotFoundError
_cache_tz = None
@ -86,7 +81,7 @@ def get_localzone_name():
# Return what we have.
if timezone is None:
raise ZoneInfoNotFoundError(tzkeyname)
raise pytz.UnknownTimeZoneError('Can not find timezone ' + tzkeyname)
return timezone
@ -95,7 +90,7 @@ def get_localzone():
"""Returns the zoneinfo-based tzinfo object that matches the Windows-configured timezone."""
global _cache_tz
if _cache_tz is None:
_cache_tz = ZoneInfo(get_localzone_name())
_cache_tz = pytz.timezone(get_localzone_name())
utils.assert_tz_offset(_cache_tz)
return _cache_tz
@ -104,6 +99,6 @@ def get_localzone():
def reload_localzone():
"""Reload the cached localzone. You need to call this if the timezone has changed."""
global _cache_tz
_cache_tz = ZoneInfo(get_localzone_name())
_cache_tz = pytz.timezone(get_localzone_name())
utils.assert_tz_offset(_cache_tz)
return _cache_tz