Skip to content

intervalContainsTime

intervalContainsTime(intervalStart: string, intervalEnd: string, pointOrStart: string, pointEnd?: string): boolean

Return true when pointOrStart lies in the half-open interval [intervalStart, intervalEnd) (3-arg), or when the inner interval [innerStart, innerEnd) lies within it (4-arg).

  • Half-open: an interval holds every clock time t with start <= t < end, so intervalEnd itself is outside (the rule CORE-6’s intervalContains uses). An empty interval (start === end) contains no point.
  • 4-arg: the inner interval must start at or after intervalStart, end at or before intervalEnd, and overlap the outer interval. An empty inner interval therefore counts only strictly inside, never at an edge (CORE-6’s clampInterval clamps it away there).
  • 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 intervalStart > intervalEnd (invalid outer interval).
  • Returns false if innerStart > innerEnd in 4-arg mode (invalid inner interval).
  • Returns false on invalid input (wrong type, malformed strings).
ParameterTypeDescription
intervalStartstringISO 8601 time string for the outer interval start
intervalEndstringISO 8601 time string for the outer interval end (excluded)
pointOrStartstringISO 8601 time string for the point (3-arg) or inner start (4-arg)
pointEndstringoptional ISO 8601 time string for the inner interval end (4-arg mode)

true if the point or inner interval is contained, or false on invalid input

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

plain/interval/intervalContainsTime.ts