intervalsOverlapUnix
Signature
Section titled “Signature”intervalsOverlapUnix(aStart: string | number, aEnd: string | number, bStart: string | number, bEnd: string | number): booleanReturn true when the half-open intervals [aStart, aEnd) and [bStart, bEnd) share at least one instant.
- Compares numeric Unix epoch values directly:
aStart < bEnd && bStart < aEnd, the same rule asintervalsOverlap(SQL:2011OVERLAPSon closed-open periods). - An interval excludes its
end, so touching intervals (aEndequal tobStart) do NOT overlap — returnsfalse. - An empty interval (
start === end) overlaps an interval only when it lies strictly inside it; at either edge, or against another empty interval, it returnsfalse. - Returns
falseif either interval is invalid (start > end). - Returns
falseon invalid input: non-numeric types, empty strings, and values that are not safe integers (fractions,NaN,±Infinity, beyond ±(2^53 − 1)).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
aStart | string | number | Unix epoch value, in the one unit all epoch arguments share — first interval start |
aEnd | string | number | Unix epoch value, in the one unit all epoch arguments share — first interval end |
bStart | string | number | Unix epoch value, in the one unit all epoch arguments share — second interval start |
bEnd | string | number | Unix epoch value, in the one unit all epoch arguments share — second interval end |
Returns
Section titled “Returns”true if intervals overlap, or false on invalid input
Examples
Section titled “Examples”import { intervalsOverlapUnix } from "@northguild/gmt/unix/interval";
intervalsOverlapUnix(0, 1700000000, 1000000, 2000000) // true