An event feed can contain recurring events, rescheduled occurrences and all-day entries. A plain sort of the raw start dates can lose an entire recurring series or put a cancelled event back on the agenda.
Choose the calendar window
Read the public ICS calendar with an iCalendar library that expands recurrence rules. Set the time zone and the start and end of the week before expanding occurrences. Keep all-day values as local calendar dates.
Reconcile updates
Identify a recurring instance by its UID and original recurrence ID. Apply exclusions, cancellations and rescheduled instances. Preserve the original identity when the start time moves.
Preview a tricky week
Test with a recurring Tuesday event moved to Wednesday and a Friday all-day event. The draft should show Wednesday once and Friday without a midnight conversion. Include the organizer’s link where supplied.