support the optional years field - #48
Merged
Merged
Conversation
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.
croncpp's README has documented an optional seventh field,
<seconds> <minutes> <hours> <days of month> <months> <days of week> <years>, and even used it in a worked example. The parser accepted exactly six fields. This implements it, as in Quartz and the Oracle format croncpp already follows.The field is optional and takes
*,,,-, and/over the range1970-2099. An expression whose years have gone by has no next occurrence, socron_nextreports failure rather than returning some later date.Traits opt in by declaring
CRON_MIN_YEARSandCRON_MAX_YEARS, detected at compile time. All three supplied traits do; a traits type written before this change keeps taking six fields and rejects a seventh, so existing custom traits are unaffected. Traits may narrow the range but not widen it — the storage range is fixed becausecronexprisn't a template, and a traits type asking for more now fails to compile with a message saying so.New
test_years.cpp, including two purpose-built traits types, one without the year members, one with a narrower range.Every expression in the README's examples table now parses, including
0 15 10 * * ? *, which never has.Fixes #22.