fix: correct recurring-event expansion in Calendar - #1238
Merged
RUKAYAT-CODER merged 1 commit intoAug 26, 2026
Conversation
Replace the 28-day MONTHLY step (addWeeks(current,4)) with addMonths(current,1) so month-end anchors keep their day-of-month, and bound the expansion loop by windowEnd instead of a fixed 52-iteration cap so DAILY fills the full ~26-week window.
|
@raihanmd Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Thank you for contributing to the project. |
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.
Replace the 28-day MONTHLY step (addWeeks(current,4)) with addMonths(current,1) so month-end anchors keep their day-of-month, and bound the expansion loop by windowEnd instead of a fixed 52-iteration cap so DAILY fills the full ~26-week window.
Description
Fixes #1046
Calendar.expandRecurringproduced wrong instances for recurring events.addWeeks(current, 4)(a fixed 28 days), so a monthly event anchored on, e.g., Jan 31 landed on Feb 28 / Mar 31 instead of the same day each month. It now steps withaddMonths(current, 1), preserving the day-of-month (month-end dates clamp correctly, e.g. Jan 31 -> Feb 28).i < 52iterations, which only yielded ~7 weeks for daily events. The loop is now bounded bywindowEnd(addWeeks(new Date(), 26)), so daily events fill the full intended ~26-week window.No new dependency
addMonthsalready ships in date-fns v3. WEEKLY and non-recurring behavior are unchanged.A focused unit test (
src/testing/events/recurrence.test.ts) covers WEEKLY (7-day steps), DAILY (full window, 1-day steps), MONTHLY (real calendar months viaaddMonths), and non-recurring passthrough.pnpm run type-checkandpnpm run lintpass; the new test passes 5/5.Related Issue
Closes #1046
Type of Change
Checklist