intervalIntersectionTime
Signature
Section titled “Signature”intervalIntersectionTime(aStart: string, aEnd: string, bStart: string, bEnd: string): { start: string; end: string; }import { intervalIntersectionTime } from "@northguild/gmt/plain/interval";Return the overlapping span of two time intervals, or null when they do not overlap.
- Uses
Temporal.PlainTime.comparefor comparison. - Adjacent intervals (e.g.
aEnd === bStart) share one instant and DO overlap. - 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 overlapping span, or null on invalid input / no overlap
Examples
Section titled “Examples”intervalIntersectionTime("09:00:00", "17:00:00", "12:00:00", "18:00:00") // { start: "12:00:00", end: "17:00:00" }intervalIntersectionTime("09:00:00", "17:00:00", "17:00:00", "18:00:00") // { start: "17:00:00", end: "17:00:00" }intervalIntersectionTime("09:00:00", "17:00:00", "18:00:00", "20:00:00") // nullintervalIntersectionTime("09:00:00", "17:00:00", "10:00:00", "11:00:00") // { start: "10:00:00", end: "11:00:00" }intervalIntersectionTime("invalid", "17:00:00", "12:00:00", "18:00:00") // null