Skip to content

intervalsOverlapUtc

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

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

  • Half-open: an interval holds every instant t with start <= t < end, so end itself is not in it. The test is aStart < bEnd && bStart < aEnd.
  • Delegates to CORE-6’s intervalsOverlap once the arguments pass the UTC-string gate, so the answer always equals intervalsOverlap({ start: aStart, end: aEnd }, { start: bStart, end: bEnd }).
  • Touching intervals (aEnd equal to bStart) share no instant and do not overlap.
  • An empty interval (start === end) overlaps only an interval it lies strictly inside.
  • Returns false if either interval is invalid (start > end).
  • Returns false on invalid input (wrong type, non-Z strings, malformed strings, leap seconds).
ParameterTypeDescription
aStartstringISO 8601 UTC datetime string for the first interval start
aEndstringISO 8601 UTC datetime string for the first interval end (excluded)
bStartstringISO 8601 UTC datetime string for the second interval start
bEndstringISO 8601 UTC datetime string for the second interval end (excluded)

true if intervals overlap, or false on invalid input

import { intervalsOverlapUtc } from "@northguild/gmt/utc/interval";
intervalsOverlapUtc("2024-01-01T09:00:00Z", "2024-01-01T13:00:00Z", "2024-01-01T12:00:00Z", "2024-01-01T17:00:00Z") // true
output 

utc/interval/intervalsOverlapUtc.ts