added tz offsets

This commit is contained in:
Daniel Tsvetkov 2019-12-10 17:28:40 +01:00
parent 4552f7502e
commit 65b24f5172

View File

@ -79,6 +79,9 @@ def normalize_words_to_number(query):
pytz_all_timezones = pytz.all_timezones pytz_all_timezones = pytz.all_timezones
NORMALIZED_TZ_DICT = dict(zip([tz.lower() for tz in pytz_all_timezones], pytz_all_timezones)) NORMALIZED_TZ_DICT = dict(zip([tz.lower() for tz in pytz_all_timezones], pytz_all_timezones))
TZ_OFFSETS = defaultdict(list)
TZ_OFFSETS_DST = defaultdict(list)
TZ_OFFSETS_NODST = defaultdict(list)
NORMALIZED_TZ_ABBR = defaultdict(set) NORMALIZED_TZ_ABBR = defaultdict(set)
TZ_ABBRS_REVERSE = defaultdict(set) TZ_ABBRS_REVERSE = defaultdict(set)
@ -89,6 +92,10 @@ for x_tz in pytz_all_timezones:
NORMALIZED_TZ_ABBR[nodst_tzname.lower()].add(x_tz) NORMALIZED_TZ_ABBR[nodst_tzname.lower()].add(x_tz)
TZ_ABBRS_REVERSE[x_tz].add(dst_tzname) TZ_ABBRS_REVERSE[x_tz].add(dst_tzname)
TZ_ABBRS_REVERSE[x_tz].add(nodst_tzname) TZ_ABBRS_REVERSE[x_tz].add(nodst_tzname)
tz_offset = pytz.timezone(x_tz).localize(datetime.now()).strftime('%z')
TZ_OFFSETS[tz_offset].append(x_tz)
TZ_OFFSETS_DST[tz_offset].append(dst_tzname)
TZ_OFFSETS_NODST[tz_offset].append(nodst_tzname)
def timezone_to_normal(query): def timezone_to_normal(query):