intervalUnionUnix
Signature
Section titled “Signature”intervalUnionUnix(aStart: string | number, aEnd: string | number, bStart: string | number, bEnd: string | number): { start: number; end: number; }import { intervalUnionUnix } from "@northguild/gmt/unix/interval";Return the combined span of two Unix epoch intervals, or null when they are disjoint.
- Compares numeric Unix epoch values directly.
- Overlapping intervals return their merged span.
- Adjacent intervals (e.g.
aEnd === bStart) share one instant and ARE merged. - 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 merged span, or null on invalid input / disjoint intervals
Examples
Section titled “Examples”intervalUnionUnix(0, 1700000000, 1000000, 2000000) // { start: 0, end: 1700000000 }intervalUnionUnix(0, 1000000, 1000000, 2000000) // { start: 0, end: 2000000 }intervalUnionUnix(0, 1000000, 1000001, 2000000) // nullintervalUnionUnix(NaN, 1700000000, 1000000, 2000000) // nullintervalUnionUnix("0", "1700000000", "1000000", "2000000") // { start: 0, end: 1700000000 }