Skip to content

fix: correct recurring-event expansion in Calendar - #1238

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
raihanmd:1046-recurring-event-expansion
Aug 26, 2026
Merged

fix: correct recurring-event expansion in Calendar#1238
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
raihanmd:1046-recurring-event-expansion

Conversation

@raihanmd

Copy link
Copy Markdown

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.expandRecurring produced wrong instances for recurring events.

  • MONTHLY drift: the step used 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 with addMonths(current, 1), preserving the day-of-month (month-end dates clamp correctly, e.g. Jan 31 -> Feb 28).
  • DAILY truncation: the loop was capped at a fixed i < 52 iterations, which only yielded ~7 weeks for daily events. The loop is now bounded by windowEnd (addWeeks(new Date(), 26)), so daily events fill the full intended ~26-week window.
    No new dependency addMonths already 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 via addMonths), and non-recurring passthrough. pnpm run type-check and pnpm run lint pass; the new test passes 5/5.

Related Issue

Closes #1046

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • No console errors
  • Uses Lucide icons consistently (no new icons added; existing usage unchanged)
  • Responsive design implemented (logic-only change; no new UI/layout)
  • Starknet best practices followed; N/A: teachLink is not a Starknet project (template artifact, left unchecked)

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.
@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER
RUKAYAT-CODER merged commit 8313110 into rinafcode:main Aug 26, 2026
6 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.

Fix inaccurate recurring-event expansion in Calendar

2 participants