diff options
-rw-r--r-- | scripts/get_calendar.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/scripts/get_calendar.py b/scripts/get_calendar.py index 89daf07..9e48852 100644 --- a/scripts/get_calendar.py +++ b/scripts/get_calendar.py @@ -12,6 +12,10 @@ from dateutil.rrule import rrulestr import icalendar import subprocess +import pytz + +berlin = pytz.timezone('Europe/Berlin') + def fetch_calendar(logger): """Fetches the calendar events and returns a icalendar.Calendar instance. """ @@ -83,12 +87,18 @@ def get_events(calendar, after, before): if 'rrule' in event: rrule = rrulestr(event['rrule'].to_ical(), dtstart=start) + if rrule._until is not None and rrule._until.tzinfo is not None: + rrule._until = rrule._until.astimezone(berlin).replace(tzinfo=None) duration = end - start - for occurence in rrule.between(after, before, True): - event_info['start'] = occurence - event_info['end'] = occurence + duration - event_info['recurring'] = True - yield copy.deepcopy(event_info) + try: + for occurence in rrule.between(after, before, True): + event_info['start'] = occurence + event_info['end'] = occurence + duration + event_info['recurring'] = True + yield copy.deepcopy(event_info) + except TypeError: + import pdb + pdb.set_trace() else: if start >= after: event_info['start'] = start |