intervalUnionTime
Signature
Section titled “Signature”intervalUnionTime(aStart: string, aEnd: string, bStart: string, bEnd: string): { start: string; end: string; }import { intervalUnionTime } from "@northguild/gmt/plain/interval";Return the combined span of two time intervals, or null when they are disjoint.
- Uses
Temporal.PlainTime.comparefor comparison. - Overlapping intervals return their merged span.
- Adjacent intervals (e.g.
aEnd === bStart) share one instant and ARE merged. - Returns
nullif either interval is invalid (start > end). - Returns
nullon 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”{ start, end } with the merged span, or null on invalid input / disjoint intervals
Examples
Section titled “Examples”intervalUnionTime("09:00:00", "17:00:00", "12:00:00", "18:00:00") // { start: "09:00:00", end: "18:00:00" }intervalUnionTime("09:00:00", "17:00:00", "17:00:00", "18:00:00") // { start: "09:00:00", end: "18:00:00" }intervalUnionTime("09:00:00", "17:00:00", "18:00:00", "20:00:00") // nullintervalUnionTime("invalid", "17:00:00", "12:00:00", "18:00:00") // null