Skip to main content

Module hours

Module hours 

Source
Expand description

Evaluation of the hours node’s schedule — the one v1 component with real branching logic, kept pure so it is directly unit-testable (feed a fixed instant, assert open/closed) without a call or a clock. The TypeScript twin is packages/flow-schema/src/hours.ts; a config is valid on one side iff it is on the other (pinned by the conformance corpus).

A flow is authored in one place and may run on a device in another timezone, so the schedule is always evaluated in the flow’s declared IANA zone (doc 48), never the device’s local time. time-tz bundles the tz database and does the UTC→zone conversion.

Enums§

HoursError
Why an hours node could not be evaluated or validated. All of these are caught at load by crate::validate, so a validated flow never produces one at run time — the engine treats it as a defect.
HoursResult
Result of evaluating an hours node: which named exit to follow.

Functions§

evaluate
Evaluate an hours node against an instant (any offset; the evaluation converts it to the flow’s zone). Returns which exit to follow. Assumes a validated config; a parse failure here is a defect surfaced as an error rather than a panic. Called only for hours nodes; any other kind is a programming error surfaced (not hidden as “closed”).
parse_date
Parse "YYYY-MM-DD" into a Date.
parse_time
Parse "HH:MM" (24-hour) into a Time.
resolve_tz
Resolve an IANA zone name, or HoursError::UnknownTimezone.
validate_config
Check every time/date string in the config parses and every range is positive (open strictly before close). Called by validation so a malformed schedule is rejected at publish, not discovered mid-call. Overnight ranges (close ≤ open) are not a v1 feature — they fail here rather than silently never matching.