summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChristian Franke <nobody@nowhere.ws>2016-05-02 14:54:12 +0200
committerChristian Franke <nobody@nowhere.ws>2016-05-02 14:54:12 +0200
commit64164b837573bed3861786706c4395f6a08aaa04 (patch)
tree446bedf69e1a2f7aa37109a203aa6bfbe9c538bb /scripts
parent17395206c241cb5dff3eedf62bb5c5aaf2ce52ee (diff)
Strip tzinfo from rrule until fields
Diffstat (limited to 'scripts')
-rw-r--r--scripts/get_calendar.py20
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