Skip to content

Serialized EXDATE sometimes breaks spec #239

@ChlorideCull

Description

@ChlorideCull

In addition, changing the source code to this, to produce an all-day event:

var now = new DateTime(2017, 1, 1);

//Repeat daily for 10 days
var rrule = new RecurrencePattern(FrequencyType.Daily, 1) { Count = 10 };

var e = new Event
{
    DtStart = new CalDateTime(now),
    RecurrenceRules = new List<IRecurrencePattern> { rrule },
};

var exceptionDateList = new PeriodList();
exceptionDateList.Add(new Period(new CalDateTime(now.AddDays(1))));
e.ExceptionDates.Add(exceptionDateList);

var calendar = new Calendar();
calendar.Events.Add(e);

var serializer = new CalendarSerializer(new SerializationContext());
var serializedCalendar = serializer.SerializeToString(calendar);

Produces this output in serializedCalendar:

BEGIN:VCALENDAR
PRODID:-//github.com/rianjs/ical.net//NONSGML ical.net 2.2//EN
VERSION:2.0
BEGIN:VEVENT
DTSTAMP:20170220T144719Z
DTSTART;VALUE=DATE:20170101
EXDATE:20170102/P1D
RRULE:FREQ=DAILY;COUNT=10
SEQUENCE:0
UID:08670eeb-76ad-46d1-bbfa-2e88f1597d58
END:VEVENT
END:VCALENDAR

In this case, EXDATE breaks the spec completely, as it's a date, but VALUE=DATE hasn't been set, and it has a weird duration suffixed to it.


In the long term, it's reasonable to consider changing ExceptionDates to not be a list of IPeriodLists. EXDATE can only be DATE-TIME or DATE according to the standard.

In the short term, suppressing duration output when serializing to ICS, and emitting the TZID parameter, should be enough.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions