Skip to content

Commit

Permalink
Fix timezone plugin when called with no TZ
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmaguire committed Feb 11, 2021
1 parent 90d42e8 commit 12d373f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugins/timezone/plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import logging
from datetime import datetime

import pytz
Expand All @@ -21,7 +20,7 @@ def get_time(self, cardinal, user, channel, msg):
tz_input = msg.split(' ', 1)[1].strip()
except IndexError:
# no timezone specified, default to UTC
return cardinal.sendMsg(channel, now.strftime(fmt))
return cardinal.sendMsg(channel, now.strftime(TIME_FORMAT))

# handle common offset formats
if (tz_input.startswith('UTC') or tz_input.startswith('GMT')) and \
Expand All @@ -37,7 +36,8 @@ def get_time(self, cardinal, user, channel, msg):
if offset is not None:
try:
if offset < 0:
# for some reason the GMT+4 == America/Eastern, and GMT-4 is over in Asia
# for some reason the GMT+4 == America/Eastern, and GMT-4
# is over in Asia
user_tz = pytz.timezone('Etc/GMT+{0}'.format(offset * -1))
elif offset > 0:
user_tz = pytz.timezone('Etc/GMT{0}'.format(offset * -1))
Expand Down

0 comments on commit 12d373f

Please sign in to comment.