summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2015-03-10 10:17:26 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2015-03-10 10:17:26 (GMT)
commite731c861ebcb52ef33296b53f2a72099a4ae5161 (patch)
tree2748234799bd567a68f7f323e83b479eb7d1dfa1
parent694a8c0b2c4215c3c5a05022e7498aecf88da7ac (diff)
downloadpykolab-e731c861ebcb52ef33296b53f2a72099a4ae5161.tar.gz
Force RRULE UNTIL attribute to be a UTC date/time but also account for it to be a date-only value
-rw-r--r--pykolab/xml/recurrence_rule.py4
-rw-r--r--tests/unit/test-003-event.py3
-rw-r--r--wallace/module_invitationpolicy.py3
3 files changed, 7 insertions, 3 deletions
diff --git a/pykolab/xml/recurrence_rule.py b/pykolab/xml/recurrence_rule.py
index 30ab10a..6f6c7d8 100644
--- a/pykolab/xml/recurrence_rule.py
+++ b/pykolab/xml/recurrence_rule.py
@@ -1,3 +1,4 @@
+import pytz
import icalendar
import datetime
import kolabformat
@@ -166,6 +167,9 @@ class RecurrenceRule(kolabformat.RecurrenceRule):
if isinstance(until, list):
until = until[0]
if isinstance(until, datetime.datetime) or isinstance(until, datetime.date):
+ # move into UTC timezone according to RFC 5545
+ if isinstance(until, datetime.datetime):
+ until = until.astimezone(pytz.utc)
self.setEnd(xmlutils.to_cdatetime(until, True))
def _set_map_value(self, val, pmap, setter):
diff --git a/tests/unit/test-003-event.py b/tests/unit/test-003-event.py
index f039ca1..4e14cd4 100644
--- a/tests/unit/test-003-event.py
+++ b/tests/unit/test-003-event.py
@@ -542,7 +542,7 @@ END:VEVENT
rrule.set_byday(['2WE','-1SU'])
rrule.setBymonth([2])
rrule.set_count(10)
- rrule.set_until(datetime.datetime(2014,7,23, 11,0,0, tzinfo=pytz.utc))
+ rrule.set_until(datetime.datetime(2014,7,23, 11,0,0, tzinfo=pytz.timezone("Europe/London")))
self.event.set_recurrence(rrule);
ical = icalendar.Calendar.from_ical(self.event.as_string_itip())
@@ -564,6 +564,7 @@ END:VEVENT
self.assertEqual(event['rrule']['BYMONTH'][0], 2)
self.assertEqual(event['rrule']['BYDAY'], ['2WE','-1SU'])
self.assertIsInstance(event['rrule']['UNTIL'][0], datetime.datetime)
+ self.assertEquals(event['rrule']['UNTIL'][0].tzinfo, pytz.utc)
def test_019_to_message_itip(self):
self.event = Event()
diff --git a/wallace/module_invitationpolicy.py b/wallace/module_invitationpolicy.py
index 72a4464..ee96634 100644
--- a/wallace/module_invitationpolicy.py
+++ b/wallace/module_invitationpolicy.py
@@ -18,7 +18,6 @@
#
import datetime
-import pytz
import os
import tempfile
import time
@@ -608,7 +607,7 @@ def process_itip_cancel(itip_event, policy, recipient_email, sender_email, recei
if itip_event['recurrence-id'] and master and itip_event['xml'].get_thisandfuture():
rrule = master.get_recurrence()
rrule.set_count(0)
- rrule.set_until(existing.get_start().astimezone(pytz.utc) + datetime.timedelta(days=-1))
+ rrule.set_until(existing.get_start() + datetime.timedelta(days=-1))
master.set_recurrence(rrule)
existing.set_recurrence_id(existing.get_recurrence_id(), True)