Permalink
Browse files

Merge pull request #45 from dbstovall/master

Apply TZID parameter to RECURRENCE-ID
  • Loading branch information...
2 parents 47fc187 + 6b699db commit 5b238950a5ce0bf05c212e9e3ccec9363646f0da @garbas garbas committed Apr 11, 2012
Showing with 16 additions and 2 deletions.
  1. +4 −1 docs/changelog.rst
  2. +12 −1 src/icalendar/cal.py
View
5 docs/changelog.rst
@@ -5,7 +5,10 @@ Changelog
3.1 (unreleased)
----------------
-* Localize datetimes for timezones to avaiod DST transition errors.
+* Apply TZID parameter to datetimes parsed from RECURRENCE-ID
+ [dbstovall]
+
+* Localize datetimes for timezones to avoid DST transition errors.
[dbstovall]
* Allow UTC-OFFSET property value data types in seconds, which follows RFC5545
View
13 src/icalendar/cal.py
@@ -398,6 +398,17 @@ def property_items(self, recursive=True):
def from_ical(st, multiple=False):
"""
Populates the component recursively from a string
+
+ RecurrenceIDs may contain a TZID parameter, if so, they should create a tz localized datetime, otherwise, create a naive datetime
+ >>> componentStr = 'BEGIN:VEVENT\\nRECURRENCE-ID;TZID=America/Denver:20120404T073000\\nEND:VEVENT'
+ >>> component = Component.from_ical(componentStr)
+ >>> component['RECURRENCE-ID'].dt.tzinfo
+ <DstTzInfo 'America/Denver' MDT-1 day, 18:00:00 DST>
+
+ >>> componentStr = 'BEGIN:VEVENT\\nRECURRENCE-ID:20120404T073000\\nEND:VEVENT'
+ >>> component = Component.from_ical(componentStr)
+ >>> component['RECURRENCE-ID'].dt.tzinfo == None
+ True
"""
stack = [] # a stack of components
comps = []
@@ -431,7 +442,7 @@ def from_ical(st, multiple=False):
factory = types_factory.for_property(name)
component = stack[-1]
try:
- if name in ('DTSTART', 'DTEND') and 'TZID' in params: # TODO: add DUE, FREEBUSY
+ if name in ('DTSTART', 'DTEND','RECURRENCE-ID') and 'TZID' in params: # TODO: add DUE, FREEBUSY
vals = factory(factory.from_ical(vals, params['TZID']))
else:
vals = factory(factory.from_ical(vals))

0 comments on commit 5b23895

Please sign in to comment.