Skip to content

implemented special characters L,W,# - #47

Merged
mariusbancila merged 1 commit into
masterfrom
feature/special-characters
Aug 12, 2026
Merged

implemented special characters L,W,##47
mariusbancila merged 1 commit into
masterfrom
feature/special-characters

Conversation

@mariusbancila

@mariusbancila mariusbancila commented Aug 12, 2026

Copy link
Copy Markdown
Owner

The README has always listed L, W and # as supported; the parser never understood any of them. This implements all three.

0 30 23 ? * 5#2    the second Friday of the month
0 30 23 ? * 5L     the last Friday of the month
0 30 23 L * ?      the last day of the month
0 30 23 LW * ?     the last weekday of the month
0 30 23 15W * ?    the weekday nearest the 15th

W never crosses into another month, and L alone in the day-of-week field means Saturday, both as in Quartz. Each qualifier applies to a single value, so 5#2,6#3 is rejected. They remain invalid in the other fields.

cronexpr now carries two option structs beside the bitsets, since the day these select depends on the month; the existing day-by-day scan consults them.

Testing L also uncovered an unrelated bug: 0 30 23 L 2 ? skipped 2012 entirely, because setting the month while the day was still 31 rolled February over into March. Fixed here too, same family as #30.

New test_special.cpp covers all three, with dates worked out from the calendar rather than read back from croncpp.

Fixes #18 and #14. Also delivers what #36 asked for, which was closed earlier by rejecting these characters instead of implementing them.

@mariusbancila
mariusbancila merged commit 1b70ab1 into master Aug 12, 2026
17 checks passed
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.

Specify the Nth day of the month not working

1 participant