Skip to content

intervalAbutsTime

intervalAbutsTime(aStart: string, aEnd: string, bStart: string, bEnd: string): boolean
import { intervalAbutsTime } from "@northguild/gmt/plain/interval";

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

  • with zero gap and zero overlap.
  • Uses Temporal.PlainTime.compare for comparison.
  • Returns true when aEnd + 1 nanosecond === bStart or bEnd + 1 nanosecond === aStart.
  • Returns false when intervals overlap, are disjoint with a gap, or are invalid.
  • Returns false on invalid input (wrong type, malformed strings).
Parameter Type Description
aStart string ISO 8601 time string for the first interval start
aEnd string ISO 8601 time string for the first interval end
bStart string ISO 8601 time string for the second interval start
bEnd string ISO 8601 time string for the second interval end

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

intervalAbutsTime("09:00:00", "12:00:00", "12:00:00.000000001", "17:00:00") // true
intervalAbutsTime("12:00:00", "17:00:00", "09:00:00", "12:00:00") // true
intervalAbutsTime("09:00:00", "12:00:00", "12:00:01", "17:00:00") // false (gap)
intervalAbutsTime("09:00:00", "13:00:00", "12:00:00", "17:00:00") // false (overlap)
intervalAbutsTime("invalid", "12:00:00", "12:00:00", "17:00:00") // false

plain/interval/intervalAbutsTime.ts