gcal-bot: Handle all-day events

(imported from commit 7395f2cdd2003b24ce59a1dbdf6f6ae24b6eae6c)
This commit is contained in:
Keegan McAllister 2013-01-16 13:51:32 -05:00
parent c9a555b605
commit 6ddbcf4799
1 changed files with 3 additions and 1 deletions

View File

@ -93,7 +93,9 @@ def get_events():
for event in feed.entry:
start = event.when[0].start.split('.')[0]
start = datetime.datetime.strptime(start, '%Y-%m-%dT%H:%M:%S')
# All-day events can have only a date
fmt = '%Y-%m-%dT%H:%M:%S' if 'T' in start else '%Y-%m-%d'
start = datetime.datetime.strptime(start, fmt)
yield (event.uid.value, start, event.title.text)
# Our cached view of the calendar, updated periodically.