Parse cron expressions and find the next time
The schedules of the agent repeat by a five-field cron expression, so
OneChat parses one with a small parser and no new dependency. A field is
a comma list of *, N, and N-M, where * and N-M can have a step. When
both day fields are restricted, a day matches when either one matches,
as in classic cron. The parser refuses names, macros, the characters ? L
W #, a seconds field, N/S, values out of range, and an expression that
matches no day in 8 years, each with an error that names the problem.
It also refuses an expression whose runs can be less than 5 minutes
apart, also across the end of an hour and across midnight. Each run is a
full turn, so a run every minute would use the weekly quota in hours.
The error gives the limit, so that the agent can ask the user.
The next time is the first matching wall time in the local zone. A wall
time that the clock skips runs later by the length of the skip, and a
wall time that the clock repeats runs once, at its first occurrence.
Issue:
60e4e4f