summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-03-04 12:02:41 -0500
committerThomas Bruederli <bruederli@kolabsys.com>2014-03-04 12:02:41 -0500
commit14a14d77a1178167614ad3bcac9e9dfe4d6e0372 (patch)
tree2cf76eb32d94f1888c8bb2f4b1e9770fc9fabceb /pykolab
parentc5ce78d75fe7d8325cf2467937bba7698db4eafc (diff)
downloadpykolab-14a14d77a1178167614ad3bcac9e9dfe4d6e0372.tar.gz
Import RRULE property from iCal
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/xml/event.py13
-rw-r--r--pykolab/xml/utils.py2
2 files changed, 14 insertions, 1 deletions
diff --git a/pykolab/xml/event.py b/pykolab/xml/event.py
index a4e10f0..afaa088 100644
--- a/pykolab/xml/event.py
+++ b/pykolab/xml/event.py
@@ -183,6 +183,13 @@ class Event(object):
if ical_event.has_key(attr):
self.set_from_ical(attr.lower(), ical_event[attr])
+ # HACK: use libkolab::EventCal::fromICal() to parse RRULEs
+ if ical_event.has_key('RRULE'):
+ from kolab.calendaring import EventCal
+ event_xml = EventCal()
+ event_xml.fromICal("BEGIN:VCALENDAR\nVERSION:2.0\n" + ical + "\nEND:VCALENDAR")
+ self.event.setRecurrenceRule(event_xml.recurrenceRule())
+
def get_attendee_participant_status(self, attendee):
return attendee.get_participant_status()
@@ -762,6 +769,9 @@ class Event(object):
return msg
+ def is_recurring(self):
+ return self.event.recurrenceRule().isValid()
+
def to_event_cal(self):
from kolab.calendaring import EventCal
return EventCal(self.event)
@@ -774,6 +784,9 @@ class Event(object):
return xmlutils.from_cdatetime(next_cdatetime, True) if next_cdatetime is not None else None
def get_occurence_end_date(self, datetime):
+ if not datetime:
+ return None
+
if not hasattr(self, 'eventcal'):
return None
diff --git a/pykolab/xml/utils.py b/pykolab/xml/utils.py
index c4d123c..780932d 100644
--- a/pykolab/xml/utils.py
+++ b/pykolab/xml/utils.py
@@ -7,7 +7,7 @@ def to_dt(dt):
Convert a naive date or datetime to a tz-aware datetime.
"""
- if isinstance(dt, datetime.date) or not hasattr(dt, 'hour'):
+ if isinstance(dt, datetime.date) and not isinstance(dt, datetime.datetime) or not hasattr(dt, 'hour'):
dt = datetime.datetime(dt.year, dt.month, dt.day, 0, 0, 0, 0)
else: