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§
- Hours
Error - Why an
hoursnode could not be evaluated or validated. All of these are caught at load bycrate::validate, so a validated flow never produces one at run time — the engine treats it as a defect. - Hours
Result - Result of evaluating an
hoursnode: which named exit to follow.
Functions§
- evaluate
- Evaluate an
hoursnode 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 forhoursnodes; any other kind is a programming error surfaced (not hidden as “closed”). - parse_
date - Parse
"YYYY-MM-DD"into aDate. - parse_
time - Parse
"HH:MM"(24-hour) into aTime. - 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.