Skip to content

intervalEngulfsDateTime

intervalEngulfsDateTime(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 moment 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 intervalContainsDateTime(aStart, aEnd, bStart, bEnd).
  • Uses Temporal.PlainDateTime.compare for comparison.
  • Returns false if either interval is invalid (start > end).
  • Returns false on invalid input (wrong type, malformed strings).
ParameterTypeDescription
aStartstringISO 8601 datetime string for the outer interval start
aEndstringISO 8601 datetime string for the outer interval end (excluded)
bStartstringISO 8601 datetime string for the inner interval start
bEndstringISO 8601 datetime string for the inner interval end (excluded)

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

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

plain/interval/intervalEngulfsDateTime.ts