fix(#47): count step values from the field minimum - #48
Merged
Merged
Conversation
*/n was checking target % n == 0, which only works when the field starts at 0. Day of month and month start at 1, so */6 on day of month matched 6, 12, 18, 24, 30 instead of 1, 7, 13, 19, 25, 31, and */3 on month gave Mar, Jun, Sep, Dec instead of Jan, Apr, Jul, Oct. _parse_arg now takes a min_value and checks (target - min_value) % n == 0. is_now passes min_value=1 for the dom and month fields. Minute, hour and day of week start at 0, so they keep the default and are unchanged. test_dom.py and test_month.py both use June 18th, and 18 is divisible by 6 and June is divisible by 2, so two of their assertions were passing on the old behaviour and had to be corrected. Added test_dom_step and test_month_step to cover dates on and off the step.
Prafyl
force-pushed
the
fix/47-step-from-minimum
branch
from
September 16, 2026 11:42
821f4b9 to
16813d8
Compare
Owner
|
Thanks, looks good 👍 |
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 #47.
*/nwas checkingtarget % n == 0, which only works when the field starts at 0. Day of month and month start at 1, so*/6on day of month matched 6, 12, 18, 24, 30 instead of 1, 7, 13, 19, 25, 31, and*/3on month gave Mar, Jun, Sep, Dec instead of Jan, Apr, Jul, Oct._parse_argnow takes amin_valueand checks(target - min_value) % n == 0.is_nowpassesmin_value=1for the dom and month fields. Minute, hour and day of week start at 0, so they keep the default and are unchanged.Two existing assertions had to change. Like you said in the issue,
test_dom.pyandtest_month.pyboth use June 18th, and 18 is divisible by 6 and June is divisible by 2, so they were passing on the old behaviour:test_dom.py:* * */6 * *is now False on the 18thtest_month.py:* * * */2 *is now False in June,* * * */5 *is now TrueAdded
test_dom_stepandtest_month_step, which use dates on and off the step and check that*/ngives the same answer as the equivalent1-31/nand1-12/n.Coverage stays at 100%, and flake8, pylint and mypy are clean.