From b64fc063c64b4b0baa140db4c126f2ff980756ab Mon Sep 17 00:00:00 2001 From: Tamar Cohen Date: Mon, 4 Mar 2019 13:52:16 -0800 Subject: [PATCH] more flexible time utils --- geocamUtil/TimeUtil.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/geocamUtil/TimeUtil.py b/geocamUtil/TimeUtil.py index 7708a19..7fac856 100644 --- a/geocamUtil/TimeUtil.py +++ b/geocamUtil/TimeUtil.py @@ -238,10 +238,11 @@ def convert_time_with_zone(event_time, timezone): tz = pytz.timezone(timezone) if not event_time.tzinfo: event_time = tz.localize(event_time) - elif event_time.tzinfo and event_time.tzinfo.zone != timezone: - # it will come in as a datetime aware time - event_time = event_time.replace(tzinfo=None) - event_time = tz.localize(event_time) + elif event_time.tzinfo: + if hasattr(event_time.tzinfo, 'zone') and event_time.tzinfo.zone != timezone: + # it will come in as a datetime aware time + event_time = event_time.replace(tzinfo=None) + event_time = tz.localize(event_time) if event_time.tzinfo != pytz.utc: event_time = timeZoneToUtc(event_time) return event_time