Calendar events can also be all day - in such a case parse the 'date' field instead of 'dateTime'

This commit is contained in:
Fabio Manganiello 2018-06-13 00:54:59 +02:00
parent e0ff431894
commit ab02d7e79c

View file

@ -62,7 +62,11 @@ class CalendarPlugin(Plugin, CalendarInterface):
events.extend(calendar.get_upcoming_events().output)
events = sorted(events, key=lambda event:
dateutil.parser.parse(event['start']['dateTime']))[:max_results]
dateutil.parser.parse(
event['start']['dateTime']
if 'dateTime' in event['start']
else event['start']['date'] + 'T00:00:00+00:00'
))[:max_results]
return Response(output=events)