UNPKG

@burglekitt/gmt

Version:

Temporal-based date and time utilities with timezone support and polyfill integration

26 lines (25 loc) 1.83 kB
/** * Return the symmetric difference of two datetime intervals — time covered by exactly one interval. * * - Uses `Temporal.PlainDateTime.compare` for comparison. * - Returns `[]` when intervals are identical or both invalid. * - Returns `[{ start, end }]` when one interval fully contains the other. * - Returns `[{ start, end }, { start, end }]` when intervals partially overlap. * - Returns `[]` if either interval is invalid (`start > end`). * - Returns `[]` on invalid input (wrong type, malformed strings). * * @param aStart ISO 8601 datetime string for the first interval start * @param aEnd ISO 8601 datetime string for the first interval end * @param bStart ISO 8601 datetime string for the second interval start * @param bEnd ISO 8601 datetime string for the second interval end * @returns array of `{ start, end }` records representing the symmetric difference, or `[]` on invalid input * * @example intervalXorDateTime("2024-01-01T09:00:00", "2024-06-30T12:00:00", "2024-04-01T11:00:00", "2024-12-31T17:00:00") // [{ start: "2024-01-01T09:00:00", end: "2024-03-31T17:00:00" }, { start: "2024-06-30T12:00:01", end: "2024-12-31T17:00:00" }] * @example intervalXorDateTime("2024-01-01T09:00:00", "2024-12-31T17:00:00", "2024-04-01T11:00:00", "2024-06-30T12:00:00") // [{ start: "2024-01-01T09:00:00", end: "2024-03-31T17:00:00" }, { start: "2024-06-30T12:00:01", end: "2024-12-31T17:00:00" }] * @example intervalXorDateTime("2024-01-01T09:00:00", "2024-12-31T17:00:00", "2024-01-01T09:00:00", "2024-12-31T17:00:00") // [] * @example intervalXorDateTime("invalid", "2024-06-30T12:00:00", "2024-07-01T13:00:00", "2024-12-31T17:00:00") // [] */ export declare function intervalXorDateTime(aStart: string, aEnd: string, bStart: string, bEnd: string): Array<{ start: string; end: string; }>;