Skip to content

Fix nickname handling and reject impossible day-of-month expressions - #17

Merged
justintout merged 5 commits into
mainfrom
bug/nicknames-and-unsatisfiable
Oct 3, 2026
Merged

justintout merged 5 commits into
mainfrom
bug/nicknames-and-unsatisfiable

Conversation

@justintout

@justintout justintout commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Fixes #13, #14, #15. One commit per issue.

Notes:

  • The issue lists 0 0 30 2,4,6 * as unsatisfiable, but April and June have a 30th; it returns 2022-04-30. The test uses 0 0 31 2,4,6 * instead.
  • isValid still returns true for impossible dates. Only the constructor rejects them.
  • The search loop has no iteration limit. The constructor check rejects every expression that could make it run forever.

Also includes #18, merged into this branch: the parser now follows Vixie cron's rules (whitespace, steps in lists, name ranges, Sunday as 0 and 7, and the */n day rule). isValid and Cron share one parse into sets of values.

An expression like "0 0 30 2 *" made nextRelativeTo and
previousRelativeTo search minute by minute forever. The constructor
now throws an ArgumentError when day-of-week is unrestricted and no
selected month contains a selected day.

Fixes #13
isValid now rejects reversed ranges, zero steps, and a day of month
that never occurs in the selected months. Previously the first two
passed validation and made nextRelativeTo loop forever, and the third
was only rejected by the Cron constructor.

Field normalization and matching move to fields.dart so isValid and
Cron share them.
Fields are now parsed once into sets of values, shared by isValid and
Cron. The parser follows Vixie cron where the old one differed:

- Fields are separated by any run of spaces or tabs.
- Steps are allowed inside lists: 1-10/2,20-30/5.
- * may appear in a list, and names work in month lists and ranges.
- Sunday is both 0 and 7: sun-sat and fri-sun are both valid.
- A day field that starts with *, such as */2, is unrestricted for the
  day-of-month/day-of-week rule, so the two fields combine with AND.
@justintout
justintout merged commit 221a017 into main Oct 3, 2026
1 check passed
@justintout justintout mentioned this pull request Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nextRelativeTo never returns for expressions that can never match

1 participant