skarim / vobject

A full-featured Python package for parsing and creating iCalendar and vCard files
http://eventable.github.io/vobject/
254 stars 90 forks source link

Custom timezones are not handled #173

Open htgoebel opened 2 years ago

htgoebel commented 2 years ago

If a vCalendar defines a "custom" timezone (VTIMEZONE), this timezone is not recognized when parsing vEvents in that calendar.

"Custom" timezones are quite common in invitations send by MS Exchange, Outlook, etc. See code below for an example.

Expected behavior

Timezones defined by VTIMEZONE in a vCalendar should be recognized when parsing vEvents - at least if the timezone is defined above the event.

In the example below. the custom timezone "(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna" should be handled like according to it's definition.

How to reproduce

import vobject

TEXT = """
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VTIMEZONE
TZID:(UTC+01:00) Amsterdam\, Berlin\, Bern\, Rome\, Stockholm\, Vienna
BEGIN:STANDARD
DTSTART:16010101T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010101T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:1-2-3-4
DTSTART;TZID="(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"
 :20200504T110000
DTEND;TZID="(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna":2
 0200504T113000
DTSTAMP:20200303T123456Z
SUMMARY:Some Appointment
END:VEVENT
END:VCALENDAR
"""

obj = (tuple(vobject.readComponents(TEXT)))[0]
obj.prettyPrint()