Skip to content

Commit

Permalink
more flexible time utils
Browse files Browse the repository at this point in the history
  • Loading branch information
tamarmot committed Mar 4, 2019
1 parent eb8e736 commit b64fc06
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions geocamUtil/TimeUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b64fc06

Please sign in to comment.