English
@eightkk/vue-weave / core / toICalendar
Function: toICalendar()
toICalendar(
events,options?):string
Defined in: src/core/interchangeICalendar.ts:214
Build an iCalendar (RFC 5545) document with one VEVENT per event: UID, DTSTAMP, DTSTART, DTEND, SUMMARY and an optional DESCRIPTION. Times are written in UTC, rounded to the nearest whole second; DTEND is written only when the rounded end is after the rounded start. Text is escaped, lines end with CRLF and are folded at 75 octets.
An event with recurrence also gets RRULE (normalized by formatRecurrenceRule, UNTIL in UTC), EXDATE and RDATE. When its recurrence.timeZone is an IANA zone other than UTC, its DTSTART, DTEND, EXDATE and RDATE are local times with that TZID, so readers repeat it at the same local time across daylight-saving changes, and the document gets one VTIMEZONE per zone, derived from Intl from the year before the zone's first event (so that its observances begin before the first event). With a nonzero recurrence.utcOffsetMinutes and no timeZone, they are local times with a fixed-offset TZID such as UTC+0900 and a VTIMEZONE of that one offset, so BYDAY, BYMONTHDAY and the local time of day keep their local meaning; fromICalendar reads such a TZID back as utcOffsetMinutes. A recurrence in UTC or without a zone is written in UTC (pass the zone the series is expanded in as recurrence.timeZone).
An event without recurrence but with seriesId and recurrenceId whose series (the event with ID seriesId and recurrence) is in the same export is an override: it is written with the series' UID and a RECURRENCE-ID in the series' zone, so readers show it in place of the occurrence it changes. fromICalendar reads it back with the ID <seriesId>:<recurrenceId>. Other events are written as before.
Throws an Error for empty or duplicate IDs, a missing summary and an invalid rule, and a RangeError for non-finite or unordered times, an invalid time zone and an invalid utcOffsetMinutes.
Parameters
events
readonly ICalendarEvent[]
options?
ICalendarOptions = {}
Returns
string