intervalXorUtc
Signature
Section titled “Signature”intervalXorUtc(aStart: string, aEnd: string, bStart: string, bEnd: string): { start: string; end: string; }[]import { intervalXorUtc } from "@northguild/gmt/utc/interval";Return the symmetric difference of two UTC intervals — time covered by exactly one interval.
- Uses
Temporal.Instant.comparefor 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, leap seconds).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
aStart |
string |
ISO 8601 UTC datetime string for the first interval start |
aEnd |
string |
ISO 8601 UTC datetime string for the first interval end |
bStart |
string |
ISO 8601 UTC datetime string for the second interval start |
bEnd |
string |
ISO 8601 UTC datetime string for the second interval end |
Returns
Section titled “Returns”array of { start, end } records representing the symmetric difference, or [] on invalid input
Examples
Section titled “Examples”intervalXorUtc("2024-01-01T09:00:00Z", "2024-06-30T12:00:00Z", "2024-04-01T11:00:00Z", "2024-12-31T17:00:00Z") // [{ start: "2024-01-01T09:00:00Z", end: "2024-03-31T17:00:00Z" }, { start: "2024-06-30T12:00:01Z", end: "2024-12-31T17:00:00Z" }]intervalXorUtc("2024-01-01T09:00:00Z", "2024-12-31T17:00:00Z", "2024-04-01T11:00:00Z", "2024-06-30T12:00:00Z") // [{ start: "2024-01-01T09:00:00Z", end: "2024-03-31T17:00:00Z" }, { start: "2024-06-30T12:00:01Z", end: "2024-12-31T17:00:00Z" }]intervalXorUtc("2024-01-01T09:00:00Z", "2024-12-31T17:00:00Z", "2024-01-01T09:00:00Z", "2024-12-31T17:00:00Z") // []intervalXorUtc("invalid", "2024-06-30T12:00:00Z", "2024-07-01T13:00:00Z", "2024-12-31T17:00:00Z") // []