operatingTimeBetween
Signature
Section titled “Signature”operatingTimeBetween(start: string, end: string, schedule: OperatingSchedule, optionsArg?: { disambiguation?: "compatible" | "earlier" | "later" | "reject" | undefined; }): stringReturn how much open time schedule has between two instants, as an exact ISO duration.
- The open time in the half-open range
[start, end): the length of its intersection withoperatingIntervals(schedule, { start, end }), summed assumIntervalssums. A support ticket raised Friday 16:00 and answered Monday 10:00 on a 09:00–17:00 weekday desk has waitedPT2Hof open time. - Hours are the largest unit (
PT40H, notP1DT16H): an open-time total has no calendar. Exact to the nanosecond, and elapsed time, not wall-clock distance, so a 00:00–00:00 window on a New York fall-back date adds 25 hours. - Holidays and overrides apply as in
operatingIntervals. start === endreturns"PT0S".- Returns
""on invalid input: an invalid instant orOperatingSchedule,startafterend, adisambiguationthat is not one of the four values, and a range spanning more than 10,000 local dates (about 27 years) counted from the datestartfalls on. - 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"". An offset to the minute has no such limit.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
start | string | ISO 8601 instant string where the clock starts (inclusive) |
end | string | ISO 8601 instant string where the clock stops (exclusive) |
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 "" when a window with such an edge reaches the range. |
Returns
Section titled “Returns”ISO 8601 duration string of the open time, or "" on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { operatingTimeBetween } from "@northguild/gmt/calendar/hours";
operatingTimeBetween("2024-06-14T20:00:00Z", "2024-06-17T14:00:00Z", { timeZone: "America/New_York", weekly: { 1: [{ from: "09:00", to: "17:00" }], 5: [{ from: "09:00", to: "17:00" }] } }) // "PT2H" — Friday 16:00 to Monday 10:00 local