Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,28 @@ def test_periodBehavior(self):
'TEST:20060216T100000/PT2H,20060516T100000/PT2H'
)

def test_rrdate_with_period(self):
"""
Test round-trip parsing and serialization of an RRULE with
an RDATE using a PERIOD.
"""

raw = "BEGIN:VCALENDAR\r\n" \
+ "VERSION:2.0\r\n" \
+ "PRODID:test\r\n" \
+ "BEGIN:VEVENT\r\n" \
+ "UID:test\r\n" \
+ "DTSTART:20000101T000000Z\r\n" \
+ "DURATION:PT1H\r\n" \
+ "DTSTAMP:20000101T000000Z\r\n" \
+ "RDATE;VALUE=PERIOD:20000102T000000Z/PT2H\r\n" \
+ "RRULE:FREQ=WEEKLY\r\n" \
+ "END:VEVENT\r\n" \
+ "END:VCALENDAR\r\n"
obj = base.readOne(raw)
serialized = obj.serialize()
self.assertEqual(raw, serialized)


class TestVTodo(unittest.TestCase):
"""
Expand Down
10 changes: 8 additions & 2 deletions vobject/icalendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,14 +876,20 @@ def transformFromNative(obj):
obj.value_param = 'DATE'
obj.value = ','.join([dateToString(val) for val in obj.value])
return obj
# Fixme: handle PERIOD case
else:
if obj.isNative:
obj.isNative = False
transformed = []
tzid = None
for val in obj.value:
if tzid is None and type(val) == datetime.datetime:
if obj.value_param == "PERIOD":
if type(val[0]) is datetime.datetime and type(val[1]) is datetime.timedelta:
transformed.append(periodToString(val))
continue
if type(val[0]) is datetime.datetime and type(val[1]) is datetime.datetime:
transformed.append(dateTimeToString(val[0]) + '/' + dateTimeToString(val[1]))
continue
if tzid is None and type(val) is datetime.datetime:
tzid = TimezoneComponent.registerTzinfo(val.tzinfo)
if tzid is not None:
obj.tzid_param = tzid
Expand Down