Skip to content

intervalAbutsUnix

intervalAbutsUnix(aStart: string | number, aEnd: string | number, bStart: string | number, bEnd: string | number): boolean
import { intervalAbutsUnix } from "@northguild/gmt/unix/interval";

Return true when two Unix intervals are exactly adjacent — one’s end equals the other’s

  • start minus 1 (no gap, no overlap).
  • Compares numeric Unix epoch values directly.
  • Returns true when aEnd + 1 === bStart or bEnd + 1 === aStart.
  • Returns false when intervals overlap, are disjoint with a gap, or are invalid.
  • Returns false on invalid input (non-numeric types, non-finite values).
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

true if intervals are exactly adjacent, or false on invalid input

intervalAbutsUnix(0, 1500000000, 1500000001, 1700000000) // true
intervalAbutsUnix(1500000001, 1700000000, 0, 1500000000) // true
intervalAbutsUnix(0, 1500000000, 1500000002, 1700000000) // false (gap)
intervalAbutsUnix(0, 1500000001, 1500000000, 1700000000) // false (overlap)
intervalAbutsUnix(NaN, 1500000000, 1500000001, 1700000000) // false

unix/interval/intervalAbutsUnix.ts