@super-calendar/core ships parseICalendar and toICalendar to convert between
.ics text and the library’s CalendarEvent shape — so a calendar built with
super-calendar can import feeds from, and export to, Google Calendar, Apple
Calendar, Outlook, and anything else that speaks iCal.
Import
parseICalendar(text) returns an array of events you can pass straight to a
<Calendar>:
uid, description,
location, plus allDay (from VALUE=DATE) and a recurrence parsed from
RRULE. Recurring events are returned as a single event with a rule — expand them
for a date range with expandRecurringEvents:
Export
toICalendar(events) produces a complete VCALENDAR string. Timed events are
written in UTC; set allDay: true for VALUE=DATE events; a recurrence becomes
an RRULE.
{ prodId, now } to set the calendar’s PRODID and the DTSTAMP written on
each event. A stable UID is derived from the event when you don’t supply one, so
re-exports stay diff-friendly.
What’s covered
A pragmatic subset of RFC 5545, aimed at real-world event interchange:VEVENTwithSUMMARY,DESCRIPTION,LOCATION,UID,DTSTART, and eitherDTENDorDURATION(e.g.PT1H30M,P1D).- All-day events via
VALUE=DATE(a missing end becomes a one-day span). - Dates in UTC (
...Z), a named IANA zone (TZID=Europe/London, resolved to the correct instant), floating local, or date-only; line folding and text escaping per the spec. RRULEround-tripped to aRecurrenceRule(FREQ,INTERVAL,COUNT,UNTIL, weeklyBYDAY, and ordinalBYDAYlike3MO/-1FR→nthWeekday), plusEXDATEexception days (recurrence.exdates, honoured byexpandRecurringEvents).
VTODO / VJOURNAL, VALARM, attendees, attachments, and
embedded VTIMEZONE definitions (a TZID must be a valid IANA name for the
runtime’s Intl). Contributions welcome.