Skip to content

Ical.Net extension for unpacking recurring events into a plain collection. Allows to view different instances of events as distinct objects. Works with iCalendar (ics) format.

License

Notifications You must be signed in to change notification settings

42ama/ical.net.unpackevents

Repository files navigation

Ical.Net UnpackEvents

This is an extension for Ical.Net, which enables the exportation of recurring events into a plain list of events. The exported events retain information enriched from their parent event.

Usage examples

// Create iCal calendar.
var calendar = new Calendar(); 

// Add a recurring event.
calendar.AddChild(new CalendarEvent
{
    Start = new CalDateTime(DateTime.Now),
    End = new CalDateTime(DateTime.Now.AddMinutes(30)),
    RecurrenceRules = new List<RecurrencePattern> {
        new RecurrencePattern(FrequencyType.Daily, 1)
    }
});

// Add plain event to expand date range to two days.
calendar.AddChild(new CalendarEvent
{
    Start = new CalDateTime(DateTime.Now.AddMinutes(60).AddDays(1)),
    End = new CalDateTime(DateTime.Now.AddMinutes(90).AddDays(1))
});


// Unpack the events into a plain list.
var actualEvents = calendar.Events.UnpackEvents(); // returns List<CalendarEvent>
var allEventsCount = 3; // In two days there are: two instances of recurring event, one plain event.

// Verify that the count of unpacked events matches the expected count.
Assert.AreEqual(allEventsCount, actualEvents.Count);

Links

About

Ical.Net extension for unpacking recurring events into a plain collection. Allows to view different instances of events as distinct objects. Works with iCalendar (ics) format.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages