Fixed an issue with timezones for all days events

Fix an issue where all day events would not be shifted by the UTC offset
Credit to emilyboda
This commit is contained in:
Ace 2020-06-14 22:58:27 +02:00
parent f8834c4c21
commit cb162a5b1e

View File

@ -127,15 +127,18 @@ class iCalendar:
re_events = ( re_events = (
{ {
'title':events.get('SUMMARY').lstrip(), 'title': events.get('SUMMARY').lstrip(),
'begin':arrow.get(events.get('DTSTART').dt).to(timezone
if arrow.get(events.get('dtstart').dt).format('HH:mm') != '00:00' 'begin': arrow.get(events.get('DTSTART').dt).to(timezone) if (
else 'UTC'), arrow.get(events.get('dtstart').dt).format('HH:mm') != '00:00')
'end':arrow.get(events.get("DTEND").dt).to(timezone else arrow.get(events.get('DTSTART').dt).replace(tzinfo=timezone),
if arrow.get(events.get('dtstart').dt).format('HH:mm') != '00:00'
else 'UTC') 'end':arrow.get(events.get("DTEND").dt).to(timezone) if (
} arrow.get(events.get('dtstart').dt).format('HH:mm') != '00:00')
for ical in recurring_events for events in ical) else arrow.get(events.get('DTEND').dt).replace(tzinfo=timezone)
} for ical in recurring_events for events in ical)
# if any recurring events were found, add them to parsed_events # if any recurring events were found, add them to parsed_events
if re_events: self.parsed_events += list(re_events) if re_events: self.parsed_events += list(re_events)
@ -150,7 +153,7 @@ class iCalendar:
if not self.parsed_events: if not self.parsed_events:
logger.debug('no events found to be sorted') logger.debug('no events found to be sorted')
else: else:
# Not working as expected.... # sort events by date
by_date = lambda event: event['begin'] by_date = lambda event: event['begin']
self.parsed_events.sort(key=by_date) self.parsed_events.sort(key=by_date)