updates ical output to convert event times to calendar timzone based time

This commit is contained in:
Raphael Maenle 2020-07-25 19:26:49 +02:00
parent 056779f7d2
commit f939127a0c

View File

@ -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