日本語
@eightkk/vue-weave / core / fromICalendar
Function: fromICalendar()
fromICalendar(
text,options?):ICalendarImport
Defined in: src/core/interchangeICalendar.ts:675
Read RFC 5545 text, such as toICalendar output or an export of a calendar application, into events. Pure string parsing without a DOM, network or file access, done with loops. Lines are unfolded (CRLF, LF or CR line ends; a leading byte order mark is removed), property names and parameter names are case-insensitive, quoted parameter values are read, and TEXT values are unescaped (backslash followed by n, comma, semicolon or backslash; any other backslash is kept as written).
Each VEVENT becomes an ICalendarImportEvent with id (UID), summary (SUMMARY, empty when missing), description when DESCRIPTION is present, start and end in epoch milliseconds. DTSTART and DTEND may be UTC (Z), floating, have a TZID parameter or be dates (VALUE=DATE). A UTC time is exact. A TZID is resolved with Intl as RFC 5545 section 3.3.5 says: a local time skipped by a daylight-saving gap is read with the UTC offset before the gap (DTSTART;TZID=America/New_York:20070311T023000 is 07:30 UTC, local 03:30), and a repeated local time takes its first occurrence. This differs from buildWorkPeriods and editing, which move a skipped time to the transition. The nonstandard prefix of /mozilla.org/…/Europe/Berlin is stripped, and VTIMEZONE definitions are not read, except that a TZID that Intl does not know but a VTIMEZONE of the file defines with one fixed offset (such as the UTC+0900 zones toICalendar writes) is read at that offset. A floating time, a date and a time with an unknown TZID (reported) are wall-clock times at options.utcOffsetMinutes. The end is DTEND, else DTSTART plus DURATION, else the start plus one day for a date and the start itself for a date-time, which is an instant like the events toICalendar writes without DTEND. For a date, DTEND is the exclusive end, so the event spans whole days as in [start, end). A DURATION (weeks, days, hours, minutes and seconds; not negative) is added as RFC 5545 says: its weeks and days to the local date and time of DTSTART, then its hours, minutes and seconds as elapsed time. So with a TZID, P1D ends at the same local time on the next day (23 or 25 hours across a daylight saving change) while PT24H is 24 hours; a local end time in a skipped or repeated hour is resolved like DTSTART. For a UTC, floating or date DTSTART, a day is 24 hours.
By default recurrence is not expanded: an event with RRULE, RDATE or EXDATE is imported once, at its first instance, with the rule in recurrenceRule, and a warning. Changed instances (RECURRENCE-ID) are skipped. With options.recurrence: 'series' the series is imported once with its parsed rule, EXDATEs and RDATEs in recurrence (in the zone of DTSTART), and changed instances become events with ID <UID>:<recurrenceId>, seriesId and recurrenceId; a rule that parseRecurrenceRule rejects keeps the default behaviour with a recurrence warning, and a RECURRENCE-ID with RANGE=THISANDFUTURE is skipped. With options.recurrence: { range } the series are replaced by their occurrences that overlap the range (expandRecurrence), changed instances take the place of the occurrences they change, and other events are kept. Properties other than the ones above, other components (VTODO, VTIMEZONE, …) and nested components such as VALARM are ignored. Problems that the reader works around are listed in warnings instead of thrown.
Throws an Error for a value that is not a string or has no BEGIN:VCALENDAR, and a RangeError for an invalid utcOffsetMinutes. The reader sets no size limit: bound the size of uploaded files yourself.
Parameters
text
string