Skip to content

isOpenAt

isOpenAt(isoString: string, schedule: OperatingSchedule, optionsArg?: { disambiguation?: "compatible" | "earlier" | "later" | "reject" | undefined; }): boolean

Return true when schedule is open at the instant isoString.

  • Open means inside one of the half-open intervals operatingIntervals returns: an opening instant is open, a closing instant is closed. Where one window ends as the next begins, the schedule stays open.
  • A window belongs to the date it starts on, so a Friday 23:00–06:00 window is open at 01:00 on Saturday even when Saturday is a holiday.
  • isoString is an instant: an offset (Z, ±HH:MM) is required, and a bracketed zone never supplies the zone — the schedule’s own zone reads the windows. Only its instant is read, a minute-rounded offset as the bracketed zone’s real one (see isValidInstant).
  • Returns false on invalid input: an invalid instant or OperatingSchedule, or a disambiguation that is not one of the four values. Check the schedule with operatingIntervals when “closed” and “invalid” must be told apart.
  • Limit at an offset with seconds. The instant is placed in the offset’s whole-minute zone, moved by its seconds, and the moved instant must be inside Temporal’s range. So within the offset’s seconds (under a minute) of the first instant Temporal supports (-271821-04-20T00:00:00Z), for an offset west of UTC, this returns false. There false is the sentinel, not a reading of the schedule. An offset to the minute has no such limit.
ParameterTypeDescription
isoStringstringISO 8601 instant string to test
scheduleOperatingSchedule{ timeZone, weekly, holidays?, overrides? } operating schedule

optionsArg

How a window edge on a clock change is resolved

OptionTypeDefaultDescription
disambiguation?"compatible" | "earlier" | "later" | "reject" (Disambiguation)"compatible", Temporal’s default.How a window edge in a repeated or skipped local hour becomes an instant, as resolveLocal resolves it. "compatible" takes the earlier instant of a repeated fall-back hour and the later one of a skipped spring-forward hour, and "earlier" and "later" take that side in both cases. "reject" returns false when a window with such an edge is the only one that could be open at isoString.

true when open at that instant, or false when closed or on invalid input

import { isOpenAt } from "@northguild/gmt/calendar/hours";
isOpenAt("2024-06-17T14:00:00Z", { timeZone: "America/New_York", weekly: { 1: [{ from: "09:00", to: "17:00" }] } }) // true — Monday 10:00 local
output 

calendar/hours/isOpenAt.ts