Skip to content

intervalEngulfsTime

intervalEngulfsTime(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 clock time 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 intervalContainsTime(aStart, aEnd, bStart, bEnd).
  • PlainTime has no day rollover: an interval never wraps past midnight. And because end is excluded, no interval contains 23:59:59.999999999 — containing it would need an end greater than it, and no PlainTime is. An interval may still have it as its end: intervalContainsTime("09:00:00", "23:59:59.999999999", "23:00:00") is true, while intervalContainsTime("09:00:00", "23:59:59.999999999", "23:59:59.999999999") is false.
  • 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 outer interval start
aEndstringISO 8601 time string for the outer interval end (excluded)
bStartstringISO 8601 time string for the inner interval start
bEndstringISO 8601 time string for the inner interval end (excluded)

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

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

plain/interval/intervalEngulfsTime.ts