Skip to content

Commit

Permalink
Support whole-day events
Browse files Browse the repository at this point in the history
Their `start` and `end` will have a `date` attribute instead of
`dateTime`
  • Loading branch information
kaeff committed Sep 1, 2021
1 parent 90174ea commit c96361e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
COPIED_EVENT_LEADING_TEXT = '[CLIENT MEETING]'

def as_datetime(time_object):
return datetime.fromisoformat(time_object['dateTime'])
iso_value = time_object['dateTime'] if 'dateTime' in time_object else time_object['date']
return datetime.fromisoformat(iso_value)

def start_and_end_equal(event1, event2):
return as_datetime(event1['start']) == as_datetime(event2['start']) and as_datetime(event1['end']) == as_datetime(event2['end'])
try:
return as_datetime(event1['start']) == as_datetime(event2['start']) and as_datetime(event1['end']) == as_datetime(event2['end'])
except KeyError as e:
raise Exception("Events lack (start,end).dateTime: %s" % {"event1": event1, "event2": event2}) from e

class Calendar:
def __init__(self, calendarId, googleService):
Expand Down

0 comments on commit c96361e

Please sign in to comment.