lpil / icalendar

🗓️ A small library for reading and writing ICalendar files.
MIT License
103 stars 56 forks source link

parse_attrs errors when dtstart/dtend are before epoch start #62

Open JamesS-M opened 2 years ago

JamesS-M commented 2 years ago

I'm parsing a calendar with a few events similar to:

BEGIN:VEVENT
DTSTART;TZID=Atlantic/Reykjavik:19681118T080000
DTEND;TZID=Atlantic/Reykjavik:19681119T080000
RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=11;BYMONTHDAY=18
DTSTAMP:20220223T132344Z
UID:040000008200E00074C5B7101A82E008000000009006137E4556CC01000000000000000
 0100000004DE18BB12CC06E4EBCC69C34D47CBB23
CREATED:20110809T103650Z
DESCRIPTION:<!-- Converted from text/plain format -->
LAST-MODIFIED:20211118T194526Z
LOCATION:
SEQUENCE:3
STATUS:CONFIRMED
SUMMARY:foobar
TRANSP:TRANSPARENT
CATEGORIES:http://schemas.google.com/g/2005#event
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:This is an event reminder
TRIGGER:-P0DT0H30M0S
END:VALARM
END:VEVENT
BEGIN:VEVENT
DTSTART:19660809T070000Z
DTEND:19660810T070000Z
RRULE:FREQ=YEARLY;UNTIL=20140809T070000Z;BYMONTH=8;BYMONTHDAY=9
DTSTAMP:20220223T132344Z
UID:040000008200E00074C5B7101A82E00800000000106972824556CC01000000000000000
 0100000007148A65B6CED4F40923DCD9292314A26
CREATED:20110809T103715Z
DESCRIPTION:
LAST-MODIFIED:20150727T163054Z
LOCATION:
SEQUENCE:1
STATUS:CONFIRMED
SUMMARY:foobar
TRANSP:TRANSPARENT
CATEGORIES:http://schemas.google.com/g/2005#event
END:VEVENT

Both of these events throw the following error, presumably because they're before unix epoch.

(CaseClauseError) no case clause matching: {:error, "Expected end of input at line 1, column 23"}
lib/icalendar/util/deserialize.ex:88: ICalendar.Util.Deserialize.parse_attr/2

Any thoughts on how to handle such old events?