From e2252f714089a07aabb69c402fc51da1720e48a2 Mon Sep 17 00:00:00 2001 From: "Dusty.P" Date: Sat, 2 Jun 2018 23:48:52 -0800 Subject: [PATCH] Adjust gti --- exts/utils.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/exts/utils.py b/exts/utils.py index 5ed6edd..01ce911 100644 --- a/exts/utils.py +++ b/exts/utils.py @@ -471,16 +471,20 @@ class Utils: try: orig_time = copy(time) split_time = time.split() - for tz in pytz.all_timezones: - if split_time[-1].lower() in tz.lower(): - time = utils.replace_text_ignorecase(time, old=split_time[-1], new='') - if tz in replace_tzs: - tz = replace_tzs['tz'] - parsed_tz = pytz.timezone(tz) - break - else: - em.set_footer(text='Valid timezone not found in time string. Using UTC...') - parsed_tz = pytz.timezone('UTC') + try: + parsed_tz = pytz.timezone(split_time[-1]) + time = utils.replace_text_ignorecase(time, old=split_time[-1], new='') + except pytz.exceptions.UnknownTimeZoneError: + for tz in pytz.all_timezones: + if split_time[-1].lower() in tz.lower(): + time = utils.replace_text_ignorecase(time, old=split_time[-1], new='') + if tz in replace_tzs: + tz = replace_tzs['tz'] + parsed_tz = pytz.timezone(tz) + break + else: + em.set_footer(text='Valid timezone not found in time string. Using UTC...') + parsed_tz = pytz.timezone('UTC') in_time = parse(time.upper()) in_time = parsed_tz.localize(in_time) except ValueError: