mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-16 02:02:58 -07:00
Update tzlocal to 2.0.0
This commit is contained in:
parent
b9a80d06e4
commit
2917b609c3
6 changed files with 166 additions and 174 deletions
|
@ -3,11 +3,14 @@ try:
|
|||
except ImportError:
|
||||
import winreg
|
||||
|
||||
from tzlocal.windows_tz import win_tz
|
||||
import pytz
|
||||
|
||||
from tzlocal.windows_tz import win_tz
|
||||
from tzlocal import utils
|
||||
|
||||
_cache_tz = None
|
||||
|
||||
|
||||
def valuestodict(key):
|
||||
"""Convert a registry key's values to a dictionary."""
|
||||
dict = {}
|
||||
|
@ -17,6 +20,7 @@ def valuestodict(key):
|
|||
dict[data[0]] = data[1]
|
||||
return dict
|
||||
|
||||
|
||||
def get_localzone_name():
|
||||
# Windows is special. It has unique time zone names (in several
|
||||
# meanings of the word) available, but unfortunately, they can be
|
||||
|
@ -81,15 +85,20 @@ def get_localzone_name():
|
|||
|
||||
return timezone
|
||||
|
||||
|
||||
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 = pytz.timezone(get_localzone_name())
|
||||
|
||||
utils.assert_tz_offset(_cache_tz)
|
||||
return _cache_tz
|
||||
|
||||
|
||||
def reload_localzone():
|
||||
"""Reload the cached localzone. You need to call this if the timezone has changed."""
|
||||
global _cache_tz
|
||||
_cache_tz = pytz.timezone(get_localzone_name())
|
||||
utils.assert_tz_offset(_cache_tz)
|
||||
return _cache_tz
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue