intervalsOverlap
Signature
Section titled “Signature”intervalsOverlap(a: Interval, b: Interval): booleanReturn true when two half-open intervals share at least one instant.
a.start < b.end && b.start < a.end. Touching intervals (a.endisb.start) do not overlap: under[start, end)the shared endpoint belongs only to the later interval.- True exactly when
intersectIntervals(a, b)is notnull. - An empty interval (
start === end) overlaps an interval it lies strictly inside, and nothing else — not at an edge, not another empty interval at the same instant (GMT rule: an empty interval covers no time, so only a strictly interior position is shared). - Compares instants: endpoints may name different zones.
- The positional
intervalsOverlapUtc,intervalsOverlapZoned,intervalsOverlapDate(…) follow the same half-open rule, so touching intervals do not overlap there either. - For zone-aligned windows (a local day, a trading session), build the endpoints with
floorToZonefirst. - Returns
falseon invalid input — either interval not anInterval, or inverted.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
a | Interval | { start, end } record of ISO 8601 instant strings |
b | Interval | { start, end } record of ISO 8601 instant strings |
Returns
Section titled “Returns”true if the intervals share an instant, or false on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { intervalsOverlap } from "@northguild/gmt/interval/compare";
intervalsOverlap({ start: "2024-01-01T09:00:00Z", end: "2024-01-01T17:00:00Z" }, { start: "2024-01-01T12:00:00Z", end: "2024-01-01T18:00:00Z" }) // true