Skip to content

intervalAbutsUnix

intervalAbutsUnix(aStart: string | number, aEnd: string | number, bStart: string | number, bEnd: string | number): boolean

Return true when two half-open Unix intervals [start, end) are exactly adjacent — one ends where the other starts, so they share no value and leave no gap (Allen’s “meets”, either order).

  • Compares numeric Unix epoch values directly.
  • Returns true when aEnd === bStart or bEnd === aStart and neither interval is empty. No value is stepped by an epoch unit.
  • Returns false when intervals overlap, are disjoint with a gap (even one epoch unit), or when either is empty (start === end): an empty interval abuts nothing.
  • Returns false on invalid input: non-numeric types, empty strings, and values that are not safe integers (fractions, NaN, ±Infinity, beyond ±(2^53 − 1)).
ParameterTypeDescription
aStartstring | numberUnix epoch value, in the one unit all epoch arguments share — first interval start
aEndstring | numberUnix epoch value, in the one unit all epoch arguments share — first interval end
bStartstring | numberUnix epoch value, in the one unit all epoch arguments share — second interval start
bEndstring | numberUnix epoch value, in the one unit all epoch arguments share — second interval end

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

import { intervalAbutsUnix } from "@northguild/gmt/unix/interval";
intervalAbutsUnix(0, 1500000000, 1500000000, 1700000000) // true
output 

unix/interval/intervalAbutsUnix.ts