diff --git a/icalHandler.py b/icalHandler.py index 0973a38..f7ba63d 100644 --- a/icalHandler.py +++ b/icalHandler.py @@ -27,7 +27,7 @@ def fetchCalendarEvents(calendars, startDate, endDate): if calendar.toggle == "True" and calendar.calendar_type == "ical": ical = iCalendar(requests.get(calendar.calendar_id).text) for event in ical.events: - + event = fitEventToCalendarTimezone(event, ical) name = event.name start = event.begin.format() end = event.end.format() @@ -38,10 +38,15 @@ def fetchCalendarEvents(calendars, startDate, endDate): if eventWithinStartEnd(startDate, endDate, event): if not eventAllDay(event): + print(start, flush=True) all_events.append(newEvent) return all_events +def fitEventToCalendarTimezone(event, calendar): + event.begin = event.begin.to(next(iter(calendar._timezones))) + event.end = event.end.to(next(iter(calendar._timezones))) + return event # converts everything to epoch seconds and utc # and then checks if at either event start or event end