Skip to content

Describe each item of a list that has a step in it - #229

Merged
bradymholt merged 2 commits into
bradymholt:masterfrom
zzoraemon043:fix/list-with-step-item
Nov 30, 2026
Merged

bradymholt merged 2 commits into
bradymholt:masterfrom
zzoraemon043:fix/list-with-step-item

Conversation

@zzoraemon043

Copy link
Copy Markdown
Contributor

What changed and why

A step only applies to its own list item (*/10,5 is every 10 minutes, plus minute 5), but the descriptor took the whole list as the step value:

Expression Before After
*/10,5 * * * * Every 10,5 minutes Every 10 minutes and at 5 minutes past the hour
0-30/10,45 * * * * Every 10,45 minutes, minutes 0 through 30 past the hour Every 10 minutes, minutes 0 through 30 past the hour and at 45 minutes past the hour
0 */6,1 * * * FormatException Every 6 hours and at 01:00 AM
0 0 */5,3 * * At 12:00 AM, every 5,3 days At 12:00 AM, every 5 days and on day 3 of the month
0 0 1 */3,2 * ..., every 3,2 months ..., every 3 months and only in February
0 12 * * 1-5/2,6 FormatException At 12:00 PM, every 2 days of the week, Monday through Friday and only on Saturday
0 12 * * MON,*/2 FormatException At 12:00 PM, only on Monday and every 2 days of the week
0 12 10 * */2,1 ..., every 2,1 days of the week ..., on day 10 of the month, every 2 days of the week and Monday

Each item of a list that has a step in it is now described on its own, the way cRonstrue does it. Lists without a step, and the existing weekly reading of TUE,FRI/4, are unchanged.

  • Day of week: when day of month is also set, plain days after the first item are only named, so it doesn't read "every 2 days of the week and or on Monday".
  • Minute/second 0 inside such a list (*/10,0) is spelled out instead of an empty item that left a trailing "and".
  • The hours-list shortcut skips lists with a step, and the weekly-interval reading skips steps followed by more items or on *; those were the FormatExceptions.

I compared 30 locales x 187 expressions (lists, ranges and steps in every field, with and without day of month, 12/24h and verbose) before and after: only lists containing a step changed.

Checklist

  • dotnet test test/Test.csproj passes (1599 passed, 11 skipped)
  • Added or updated tests for the change (TestListWithStepItem, TestDayOfWeekListWithStepItem, both fail before the change)
  • For a new language: added it to the README table, the demo language list and the csproj <Description> (see CONTRIBUTING.md)

A step only applies to its own list item, but */10,5 was described as "every 10,5 minutes" and steps in hour and day-of-week lists threw. Each item of such a list is now described on its own, as cRonstrue does.
string[] itemDescriptions = expression.Split(',')
.Select((segment, i) =>
{
string itemDescription = GetSegmentDescription(segment, allDescription, getSingleItemDescription,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A start-offset step inside a month or year list isn't expanded to a range the way it is on its own, so 0 0 1 3/2,12 * reads "every 2 months, starting only in March and only in December" while 0 0 1 3/2 * reads "March through December". I think a test with 3/2,12 and an expanded item could cover it. WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. The parser now expands each list item, so 3/2,12 reads "every 2 months, March through December and only in December". A DOW list with the step last (TUE,FRI/4) stays a weekly interval. Tests for 3/2,12, 1,3/4 and 0 12 10 * 3/2,1 in cd39527.

@bradymholt
bradymholt merged commit c5d89cf into bradymholt:master Nov 30, 2026
3 checks passed
@github-actions

Copy link
Copy Markdown

The changes in PR were just released in 3.6.0 🎉.

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.

2 participants