intervalIntersectionUnix
Signature
Section titled “Signature”intervalIntersectionUnix(aStart: string | number, aEnd: string | number, bStart: string | number, bEnd: string | number): { start: number; end: number; } | nullReturn the overlapping span of two half-open Unix epoch intervals [start, end), or null when they do not overlap.
- Compares numeric Unix epoch values directly.
- The result is
[max(aStart, bStart), min(aEnd, bEnd)), and it exists only whenintervalsOverlapUnixis true — the same rule asintersectIntervals. - Touching intervals (e.g.
aEnd === bStart) share no instant, because eachendis excluded, and returnnull. - An empty interval (
start === end) strictly inside the other returns itself; at either edge, or against another empty interval, it returnsnull. - Returns
nullif either interval is invalid (start > end). - Returns
nullon 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”{ start, end } with the overlapping span, or null on invalid input / no overlap
Members
| Member | Type | Description |
|---|---|---|
start | number | The instant the interval begins at, as a Unix epoch number in the unit the arguments share. |
end | number | The first instant after the interval, in the same unit as start. It is exclusive: the interval holds everything from start up to but not including this value. It can equal start, which makes the interval empty. |
Examples
Section titled “Examples”import { intervalIntersectionUnix } from "@northguild/gmt/unix/interval";
intervalIntersectionUnix(0, 1700000000, 1000000, 2000000) // { start: 1000000, end: 2000000 }