isOpenAt
Signature
Section titled “Signature”isOpenAt(isoString: string, schedule: OperatingSchedule, optionsArg?: { disambiguation?: "compatible" | "earlier" | "later" | "reject" | undefined; }): booleanReturn true when schedule is open at the instant isoString.
- Open means inside one of the half-open intervals
operatingIntervalsreturns: 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.
isoStringis 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 (seeisValidInstant).- Returns
falseon invalid input: an invalid instant orOperatingSchedule, or adisambiguationthat is not one of the four values. Check the schedule withoperatingIntervalswhen “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 returnsfalse. Therefalseis the sentinel, not a reading of the schedule. An offset to the minute has no such limit.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
isoString | string | ISO 8601 instant string to test |
schedule | OperatingSchedule | { timeZone, weekly, holidays?, overrides? } operating schedule |
Options
Section titled “Options”optionsArg
How a window edge on a clock change is resolved
| Option | Type | Default | Description |
|---|---|---|---|
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. |
Returns
Section titled “Returns”true when open at that instant, or false when closed or on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”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