Rick DeNatale
2008-Sep-21 21:52 UTC
[iCalendar-devel] Patch to capture tzid of events on icalendar parsing
I have need to import icalendar format data from apps like google calendar and ical.app, both of which produce datetime values with specified timezones. Neither the icalendar gem nor it''s competitor vpim support this. I forked icalendar this afternoon to add "the simplest code that could work". I''ve punted so far on actually using the timezone components in the imported file since both google calendar and ical.app seem to use timezone ids which are recognized by the TZInfo gem. My fork is at git://github.com/rubyredrick/icalendar.git Here''s my commit comment with some more details. Added timezone awareness to datetime attributes DateTime now has icalendar_tzid and icalendar_tzid= methods This is to provide support for conformance with RFC 2445 Section 4.3.5, when PARSING icalendar input Parsing a component property which is a datetime will set this to: UTC if the value for the datetime ends with Z, e.g. DTSTART:19970903T163000Z corresponding to FORM #2, DATE WITH UTC TIME in the RFC The specified TZID parameter value if specified in the attribute line, e.g. DTSTART;TZID=America/Chicago:19970903T163000 corresponding to FORM #3 DATE WITH LOCAL TIME AND TIMEZONE REFERENCE nil otherwise, e.g. DTSTART:19970903T163000 corresponding to FORM #1 DATE WITH LOCAL TIME The datetime is NOT adjusted for timezone when the property is parsed. The adjustment SHOULD be done using the timezone components in the containing calendar, however it may be possible to use the TZInfo gem to do the conversion when processing input from google calendar, and ical.app on the Macintosh since both seem to use tzids which are in the Olsen Timezone database used by TZInfo and MS Outlook seems to output datetimes in FORM #2. Since I currently have no need to export icalendar format with anything other than FORM 2 datetimes, there is minimal support for export. The only thing I have done is to output either a FORM 2, or FORM 1 value string for a datetime depending on whether or not icalendar_tzid is set to "UTC" -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/icalendar-devel/attachments/20080921/53ebbd52/attachment.html>