intervalIntersectionUnix
Signature
Section titled “Signature”intervalIntersectionUnix(aStart: string | number, aEnd: string | number, bStart: string | number, bEnd: string | number): { start: number; end: number; }import { intervalIntersectionUnix } from "@northguild/gmt/unix/interval";Return the overlapping span of two Unix epoch intervals, or null when they do not overlap.
- Compares numeric Unix epoch values directly.
- Adjacent intervals (e.g.
aEnd === bStart) share one instant and DO overlap. - Returns
nullif either interval is invalid (start > end). - Returns
nullon invalid input (non-numeric types, non-finite values).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
aStart |
string | number |
Unix epoch value (seconds or milliseconds) — first interval start |
aEnd |
string | number |
Unix epoch value (seconds or milliseconds) — first interval end |
bStart |
string | number |
Unix epoch value (seconds or milliseconds) — second interval start |
bEnd |
string | number |
Unix epoch value (seconds or milliseconds) — second interval end |
Returns
Section titled “Returns”{ start, end } with the overlapping span, or null on invalid input / no overlap
Examples
Section titled “Examples”intervalIntersectionUnix(0, 1700000000, 1000000, 2000000) // { start: 1000000, end: 1700000000 }intervalIntersectionUnix(0, 1000000, 1000000, 2000000) // { start: 1000000, end: 1000000 }intervalIntersectionUnix(0, 1000000, 1000001, 2000000) // nullintervalIntersectionUnix(NaN, 1700000000, 1000000, 2000000) // nullintervalIntersectionUnix("0", "1700000000", "1000000", "2000000") // { start: 1000000, end: 1700000000 }