Can someone give me an example of generating a VTIMEZONE section of an icalendar file using the python icalendar library?
I believe this can be done by using the icalendar.cal.Timezone Component class, but don't yet know exactly how.
Preferably, the resulting portion of the icalendar file would be similar to this exported sample from the Mac OS X ICal program (or be analogous, but still valid icalendar format).
BEGIN:VTIMEZONE
TZID:America/Denver
BEGIN:DAYLIGHT
TZOFFSETFROM:-0700
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
DTSTART:20070311T020000
TZNAME:MDT
TZOFFSETTO:-0600
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0600
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
DTSTART:20071104T020000
TZNAME:MST
TZOFFSETTO:-0700
END:STANDARD
END:VTIMEZONE
So far I have this working code, but it doesn't include the needed STANDARD and DAYLIGHT VTIMEZONE elements.
import icalendar
timezone = icalendar.cal.Timezone()
timezone.add('TZID', 'America/Denver')
timezone.to_ical()
Currently it seems not to be possible, at least not with heavy hacking using pytz.
There is an ongoing discussion with fairly recent updates on the corresponding icalendar issue. You can find some hacky code there.
This other icalendar issue seems to be where something will be implemented for the VTIMEZONE->icalendar conversion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With