allenporter/ical

Event does not have correct default when no end or duration is specified

dannycjones opened this issue · 1 comments

Describe the bug

Calendar events that do not specify DTEND or DURATION do not respect default in RFC 2445, and instead raise exception ValueError("Unexpected state with no duration or dtend").

To Reproduce

Here's the contents of an ICS file I am trying to use.

BEGIN:VCALENDAR
PRODID:-//127.0.0.1//Waste Calendar Generator//
VERSION:2.0
X-WR-CALNAME:Bins Schedule
X-WR-CALDESC:Bins Schedule
X-WR-TIMEZONE:Europe/London
BEGIN:VEVENT
DTSTART;VALUE=DATE:20231212
SUMMARY:Black Bin Collection
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20231219
SUMMARY:Green Bin Collection
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20231219
SUMMARY:Blue Bin Collection
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20231228
SUMMARY:Black Bin Collection
END:VEVENT
END:VCALENDAR

Expected behavior

The library should treat infer a sensible default where a duration or end date/time has not been specified.

According to RFC 2445, section 4.6.1:

For cases where a "VEVENT" calendar component specifies a "DTSTART" property with a DATE data type but no "DTEND" property, the events non-inclusive end is the end of the calendar date specified by the "DTSTART" property. For cases where a "VEVENT" calendar component specifies a "DTSTART" property with a DATE-TIME data type but no "DTEND" property, the event ends on the same calendar date and time of day specified by the "DTSTART" property.

Additional context

I'm trying to use an ICS file provided by my local government authority that describes bin collections and integrate that with my Home Assistant. I do not have any control over the ICS file itself, but it looks to be valid (at least with respect to absent DTEND, DURATION).

I'm also working on a fix, and will open a PR for this.

I've opened PR #258 to address this issue.