fix(tasks): don't skip a month when a monthly task repeats from the 29th-31st - #3436
Open
TowyTowy wants to merge 1 commit into
Open
fix(tasks): don't skip a month when a monthly task repeats from the 29th-31st#3436TowyTowy wants to merge 1 commit into
TowyTowy wants to merge 1 commit into
Conversation
…9th-31st addOneMonthToDate passed d.Month()+1 with the original day straight into time.Date, which normalizes an out-of-range day forward. A task repeating monthly and due Jan 31 got a new due date of Mar 3: February was skipped and the day of month stayed shifted for every following occurrence (Apr 3, May 3, ...). Same for Mar 31 -> May 1, May 31 -> Jul 1. Clamp the day to the last day of the target month instead, so Jan 31 repeats to Feb 28 (Feb 29 in a leap year). This matches the "Monthly" label in the UI and the FREQ=MONTHLY;BYMONTHDAY=<n> rule the CalDAV export already emits for this repeat mode, neither of which allows an occurrence to land in the month after next. Co-Authored-By: Claude <noreply@anthropic.com>
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.
addOneMonthToDatepassesd.Month()+1with the original day intotime.Date, which normalizes an out-of-range day forward rather than clamping it.A task with repeat mode "Monthly" and a due date of Jan 31 gets a new due date of Mar 3 — February is skipped, and the day of month stays shifted for every occurrence after that (Apr 3, May 3, ...). Same for Mar 31 -> May 1 and May 31 -> Jul 1. It applies to the reminders, start date and end date of the mode too.
This clamps the day to the last day of the target month instead, so Jan 31 repeats to Feb 28 (Feb 29 in a leap year). That matches the "Monthly" label in the UI, and the
FREQ=MONTHLY;BYMONTHDAY=<n>rule the CalDAV export already emits for this mode — under RFC 5545 an occurrence can never land in the month after next.Added a table test for
addOneMonthToDate(short month, leap February, 30-day month, year boundary) and anupdateDonecase for the end-of-month due date. Both fail on main and pass with the fix; the rest ofpkg/modelsis unaffected — no fixture usesrepeat_mode: 1.I'm aware of #3071 replacing this code path for 3.0.0. Filing anyway since the current behaviour ships until then — happy to close it if you'd rather not carry the change.
AI disclosure: written with Claude Code, reviewed and tested before opening.