intervalsOverlapUtc
Signature
Section titled “Signature”intervalsOverlapUtc(aStart: string, aEnd: string, bStart: string, bEnd: string): booleanReturn true when the half-open UTC intervals [aStart, aEnd) and [bStart, bEnd) share at least one instant.
- Half-open: an interval holds every instant
twithstart <= t < end, soenditself is not in it. The test isaStart < bEnd && bStart < aEnd. - Delegates to CORE-6’s
intervalsOverlaponce the arguments pass the UTC-string gate, so the answer always equalsintervalsOverlap({ start: aStart, end: aEnd }, { start: bStart, end: bEnd }). - Touching intervals (
aEndequal tobStart) share no instant and do not overlap. - An empty interval (
start === end) overlaps only an interval it lies strictly inside. - Returns
falseif either interval is invalid (start > end). - Returns
falseon invalid input (wrong type, non-Zstrings, 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 (excluded) |
bStart | string | ISO 8601 UTC datetime string for the second interval start |
bEnd | string | ISO 8601 UTC datetime string for the second interval end (excluded) |
Returns
Section titled “Returns”true if intervals overlap, or false on invalid input
Examples
Section titled “Examples”import { intervalsOverlapUtc } from "@northguild/gmt/utc/interval";
intervalsOverlapUtc("2024-01-01T09:00:00Z", "2024-01-01T13:00:00Z", "2024-01-01T12:00:00Z", "2024-01-01T17:00:00Z") // true