Recurrence: unsorted BYMONTHDAY returns non-earliest date; YEARLY ignores all but first #11

Closed
opened 2026-06-05 10:26:13 +00:00 by victor · 0 comments
Owner

MONTHLY next_occurrence (src/core/recurrence.rs:245-251) iterates by_month_day in the order given and returns the first candidate > after, not the minimum. With an unsorted list (e.g. BYMONTHDAY=15,1) it can return a later day than the earliest valid one.

The YEARLY branch (lines 273-277) is worse: it only ever uses by_month_day[0], ignoring any additional values.

Fix: sort by_month_day ascending (and scan months/years in order, picking the minimum valid candidate > after); handle multiple BYMONTHDAY values in the YEARLY branch too. Add tests with multi-value and unsorted BYMONTHDAY for both MONTHLY and YEARLY.

Found in review.

MONTHLY `next_occurrence` (src/core/recurrence.rs:245-251) iterates `by_month_day` in the order given and returns the *first* candidate `> after`, not the minimum. With an unsorted list (e.g. `BYMONTHDAY=15,1`) it can return a later day than the earliest valid one. The YEARLY branch (lines 273-277) is worse: it only ever uses `by_month_day[0]`, ignoring any additional values. **Fix:** sort `by_month_day` ascending (and scan months/years in order, picking the minimum valid candidate `> after`); handle multiple BYMONTHDAY values in the YEARLY branch too. Add tests with multi-value and unsorted BYMONTHDAY for both MONTHLY and YEARLY. Found in review.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
victor/task-manager#11
No description provided.