Repository navigation
Fix nickname handling and reject impossible day-of-month expressions - #17
Merged
Merged
Conversation
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.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13, #14, #15. One commit per issue.
@rebootbefore the validity check, so its specific "not supported" error message is reachable.@midnightto0 0 * * *, matching@daily. Adds a test that every nickname agrees with its crontab(5) expansion.Cronthrows anArgumentErrorwhen day-of-week is*and no selected month contains a selected day (e.g.0 0 30 2 *). PreviouslynextRelativeToandpreviousRelativeTosearched forever. When day-of-week is restricted, the POSIX either-field rule guarantees a match, so those expressions are still accepted.Notes:
0 0 30 2,4,6 *as unsatisfiable, but April and June have a 30th; it returns2022-04-30. The test uses0 0 31 2,4,6 *instead.isValidstill returnstruefor impossible dates. Only the constructor rejects them.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
*/nday rule).isValidandCronshare one parse into sets of values.