[icalendar-dev] Problems parsing iCal offset alarm triggers
David Riley
icalendar at driley.moonfall.com
Tue May 8 21:27:38 CEST 2007
I'm having trouble parsing the ics files generated by iCal, specifically
timestamps such as -PT6H with iCalendar 1.2, Python 2.3.5.
It appears as if this value is initially parsed and converted into an
internal timedelta which is normalized to -1 day, -18 hours. That is then
used internally to generate the string value which is used by all the
iteration routines (-P1DT18H). Unfortunately, if you try to decode that,
it ends up decoding that as 1 day 18 hours, and then normalizing it again,
giving it an incorrect value.
Here's the example ics file:
--
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//Apple Computer\, Inc//iCal 2.0//EN
VERSION:2.0
BEGIN:VEVENT
DTSTART;TZID=America/Vancouver:20070613T120000
DTEND;TZID=America/Vancouver:20070613T130000
SUMMARY:sample event
UID:918DBC63-C942-47E9-85F7-D81FD126E891
SEQUENCE:2
DTSTAMP:20061215T172910Z
BEGIN:VALARM
TRIGGER:-P7D
X-WR-ALARMUID:B96A7FCB-2432-4EFA-9E9B-EB08FA2F7B53
ATTACH;VALUE=URI:Basso
ACTION:AUDIO
END:VALARM
BEGIN:VALARM
ACTION:AUDIO
X-WR-ALARMUID:FEEA1FE2-1533-4FC0-8C16-D81D9398D57A
ATTACH;VALUE=URI:Basso
TRIGGER:-PT6H
END:VALARM
END:VEVENT
END:VCALENDAR
--
Here's the program I used to display it:
--
#!/usr/bin/python
from icalendar import Calendar
data = open( 'test.ics', 'rb' ).read()
cal = Calendar.from_string( data )
print cal
--
Here is the internal representation after being parsed:
--
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//Apple Computer\, Inc//iCal 2.0//EN
VERSION:2.0
BEGIN:VEVENT
DTEND;TZID=America/Vancouver:20070613T130000
DTSTAMP:20061215T172910Z
DTSTART;TZID=America/Vancouver:20070613T120000
SEQUENCE:2
SUMMARY:sample event
UID:918DBC63-C942-47E9-85F7-D81FD126E891
BEGIN:VALARM
ACTION:AUDIO
ATTACH;VALUE=URI:Basso
TRIGGER:-P7D
X-WR-ALARMUID:B96A7FCB-2432-4EFA-9E9B-EB08FA2F7B53
END:VALARM
BEGIN:VALARM
ACTION:AUDIO
ATTACH;VALUE=URI:Basso
TRIGGER:-P1DT18H
X-WR-ALARMUID:FEEA1FE2-1533-4FC0-8C16-D81D9398D57A
END:VALARM
END:VEVENT
END:VCALENDAR
--
Has anybody run into this issue before? It feels like vDuration.ical()
should be checking if self is negative, and then taking the absolute value
of it, before converting to an ical string.
--
David Riley
More information about the icalendar-dev
mailing list