summaryrefslogtreecommitdiffstats
path: root/pykolab/xml/event.py
diff options
context:
space:
mode:
Diffstat (limited to 'pykolab/xml/event.py')
-rw-r--r--pykolab/xml/event.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/pykolab/xml/event.py b/pykolab/xml/event.py
index 0e7c333..72c5e07 100644
--- a/pykolab/xml/event.py
+++ b/pykolab/xml/event.py
@@ -1134,17 +1134,21 @@ class Event(object):
from kolab.calendaring import EventCal
return EventCal(self.event)
- def get_next_occurence(self, datetime):
+ def get_next_occurence(self, _datetime):
if not hasattr(self, 'eventcal'):
self.eventcal = self.to_event_cal()
- next_cdatetime = self.eventcal.getNextOccurence(xmlutils.to_cdatetime(datetime, True))
+ next_cdatetime = self.eventcal.getNextOccurence(xmlutils.to_cdatetime(_datetime, True))
next_datetime = xmlutils.from_cdatetime(next_cdatetime, True) if next_cdatetime is not None else None
# cut infinite recurrence at a reasonable point
- if next_datetime and not self.get_last_occurrence() and next_datetime > self._recurrence_end():
+ if next_datetime and not self.get_last_occurrence() and next_datetime > xmlutils.to_dt(self._recurrence_end()):
next_datetime = None
+ # next_datetime is always a cdatetime, convert to date if necessary
+ if not isinstance(self.get_start(), datetime.datetime):
+ next_datetime = datetime.date(next_datetime.year, next_datetime.month, next_datetime.day)
+
return next_datetime
def get_occurence_end_date(self, datetime):