Fixed event merging bug

This commit is contained in:
Maximilian Giller 2020-05-08 10:10:31 +02:00
parent b7ede5a026
commit eaa3de9d79

View file

@ -3,6 +3,7 @@ from datetime import datetime, timezone, timedelta, date
from dateutil.rrule import rrulestr from dateutil.rrule import rrulestr
from dateutil.parser import parse from dateutil.parser import parse
import calendar import calendar
from CalendarEvent import CalendarEvent
class CalendarInterface (DataSourceInterface): class CalendarInterface (DataSourceInterface):
@ -79,7 +80,7 @@ class CalendarInterface (DataSourceInterface):
# Is excluded? # Is excluded?
if event.calendar_url in self.excluded_urls: if event.calendar_url in self.excluded_urls:
continue continue
event_occurrence = self.__get_if_event_in_range__( event_occurrence = self.__get_if_event_in_range__(
event, start, duration) event, start, duration)
if event_occurrence: if event_occurrence:
@ -135,11 +136,31 @@ class CalendarInterface (DataSourceInterface):
raise ex raise ex
def __merge_event_data__(self, event, start=None): def __merge_event_data__(self, event, start=None):
if start is not None: merged_event = CalendarEvent()
event.begin_datetime = start
event.end_datetime = start + event.duration merged_event.begin_datetime = event.begin_datetime
merged_event.end_datetime = event.end_datetime
merged_event.duration = event.duration
merged_event.allday = event.allday
merged_event.multiday = event.multiday
merged_event.rrule = event.rrule
return event merged_event.title = event.title
merged_event.description = event.description
merged_event.attendees = event.attendees
merged_event.highlight = event.highlight
merged_event.calendar_name = event.calendar_name
merged_event.calendar_url = event.calendar_url
merged_event.location = event.location
merged_event.fetch_datetime = event.fetch_datetime
if start is not None:
merged_event.begin_datetime = start
merged_event.end_datetime = start + event.duration
return merged_event
def __add_timezoneawarness__(self, rrule): def __add_timezoneawarness__(self, rrule):
"""UNTIL must be specified in UTC when DTSTART is timezone-aware (which it is)""" """UNTIL must be specified in UTC when DTSTART is timezone-aware (which it is)"""