intervalXorTime
Signature
Section titled “Signature”intervalXorTime(aStart: string, aEnd: string, bStart: string, bEnd: string): { start: string; end: string; }[]import { intervalXorTime } from "@northguild/gmt/plain/interval";Return the symmetric difference of two time intervals — time covered by exactly one interval.
- Uses
Temporal.PlainTime.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).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
aStart |
string |
ISO 8601 time string for the first interval start |
aEnd |
string |
ISO 8601 time string for the first interval end |
bStart |
string |
ISO 8601 time string for the second interval start |
bEnd |
string |
ISO 8601 time 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”intervalXorTime("09:00:00", "12:00:00", "11:00:00", "17:00:00") // [{ start: "09:00:00", end: "10:59:59" }, { start: "12:00:01", end: "17:00:00" }]intervalXorTime("09:00:00", "17:00:00", "11:00:00", "12:00:00") // [{ start: "09:00:00", end: "10:59:59" }, { start: "12:00:01", end: "17:00:00" }]intervalXorTime("09:00:00", "17:00:00", "09:00:00", "17:00:00") // []intervalXorTime("09:00:00", "12:00:00", "13:00:00", "17:00:00") // [{ start: "09:00:00", end: "12:00:00" }, { start: "13:00:00", end: "17:00:00" }]intervalXorTime("invalid", "12:00:00", "13:00:00", "17:00:00") // []