datetime/calendar_diff_utils library

Calendar diff: added / removed / changed events between two snapshots — roadmap #608.

Given an "before" and "after" list of events keyed by a stable id, this classifies each event into added (only in after), removed (only in before), or changed (same id, but a differing start, end, or title). It is the core of sync reconciliation, "what changed since last refresh" banners, and calendar-merge conflict UIs — logic apps routinely reimplement with ad-hoc map juggling.

Identity is the CalendarEvent.id; equality for the changed/unchanged decision compares start, end, and title. Two events with the same id are assumed to be the same logical event observed at two times.

Classes

CalendarEvent
A minimal calendar event: a stable id plus its start, end, and title. Apps with richer models can map to and from this for diffing.

Functions

diffCalendars(List<CalendarEvent> before, List<CalendarEvent> after) CalendarDiff
Diffs before against after, pairing events by CalendarEvent.id.

Typedefs

CalendarChange = ({CalendarEvent after, CalendarEvent before})
One event that changed: its before and after states (same id).
CalendarDiff = ({List<CalendarEvent> added, List<CalendarChange> changed, List<CalendarEvent> removed})
The classified difference between two calendar snapshots.