Skip to content

intervalsOverlapTime

intervalsOverlapTime(aStart: string, aEnd: string, bStart: string, bEnd: string): boolean

Return true when the half-open time intervals [aStart, aEnd) and [bStart, bEnd) share at least one clock time.

  • Half-open: an interval holds every t with start <= t < end, so end itself is not in it (the rule CORE-6’s intervalsOverlap uses). The test is aStart < bEnd && bStart < aEnd.
  • Touching intervals (aEnd equal to bStart) share no time and do not overlap.
  • An empty interval (start === end) overlaps only an interval it lies strictly inside.
  • PlainTime has no day rollover: an interval never wraps past midnight.
  • Uses Temporal.PlainTime.compare for comparison.
  • Returns false if either interval is invalid (start > end).
  • Returns false on invalid input (wrong type, malformed strings).
ParameterTypeDescription
aStartstringISO 8601 time string for the first interval start
aEndstringISO 8601 time string for the first interval end (excluded)
bStartstringISO 8601 time string for the second interval start
bEndstringISO 8601 time string for the second interval end (excluded)

true if intervals overlap, or false on invalid input

import { intervalsOverlapTime } from "@northguild/gmt/plain/interval";
intervalsOverlapTime("09:00:00", "17:00:00", "12:00:00", "18:00:00") // true
output 

plain/interval/intervalsOverlapTime.ts