Skip to content

intervalEngulfsUtc

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

Return true when the half-open interval B [bStart, bEnd) lies within the half-open interval A [aStart, aEnd) — every instant of B is also in A.

  • Half-open: an interval holds every t with start <= t < end. B may start at A’s start and end at A’s end, because neither end is part of either interval.
  • B must also overlap A, so an empty B (bStart === bEnd) counts only strictly inside A, never at an edge (CORE-6’s clampInterval clamps it away there).
  • Equivalent to 4-argument intervalContainsUtc(aStart, aEnd, bStart, bEnd).
  • Uses Temporal.Instant.compare for comparison.
  • 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 outer interval start
aEndstringISO 8601 UTC datetime string for the outer interval end (excluded)
bStartstringISO 8601 UTC datetime string for the inner interval start
bEndstringISO 8601 UTC datetime string for the inner interval end (excluded)

true if B lies within A, or false on invalid input

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

utc/interval/intervalEngulfsUtc.ts