collective / icalendar

icalendar parser library for Python
https://icalendar.readthedocs.io/en/latest/
Other
979 stars 167 forks source link

Unable to parse ics file with VTIMEZONE #218

Open ddui opened 7 years ago

ddui commented 7 years ago

When trying to pass the following .ics

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//TEST//TEST//EN
BEGIN:VTIMEZONE
TZID:UTC+11
BEGIN:STANDARD
DTSTART;VALUE=DATE:20170101
TZNAME:UTC+11
TZOFFSETFROM:+1100
TZOFFSETTO:+1100
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DESCRIPTION:TESTING
DTEND;TZID=UTC+11:20170228T233000
DTSTAMP:20170227T064302Z
DTSTART;TZID=UTC+11:20170228T230000
RESOURCES:Court 4
SEQUENCE:0
STATUS:Confirmed
SUMMARY:TESTIN
UID:1961094_636238800000000000
END:VEVENT
END:VCALENDAR

If I remove the VTIMEZONE section the file parses perfectly well. If I dont, when "walk"ing through events the DTSTART= none and DTEND = none

When I do a print (event['DTSTART'].dt) I get back AttributeError: 'NoneType' object has no attribute 'dt'

Unfortunately, I cant get the source ics file changed.

geier commented 7 years ago

The issue here is that the VTIMEZONE subcomponent's DTSTART is a date, not a datetime. In most cases we currently don't support invalid VCALENDARs.

Some error reporting would be nice in any case,

Quote from RFC 5545:

The mandatory "DTSTART" property gives the effective onset date and local time for the time zone sub-component definition. "DTSTART" in this usage MUST be specified as a date with a local time value.