Skip to content

Fix current day detection and duplicate day numbering bugs - #27

Open
shubamchaudhary wants to merge 1 commit into
mainfrom
claude/add-save-progress-feature-011CV5kPahrBqqmGjH6fc78e
Open

Fix current day detection and duplicate day numbering bugs#27
shubamchaudhary wants to merge 1 commit into
mainfrom
claude/add-save-progress-feature-011CV5kPahrBqqmGjH6fc78e

Conversation

@shubamchaudhary

Copy link
Copy Markdown
Owner

Bug Fixes:

  1. Fixed wrong day selection (e.g., Day 2 highlighted instead of Day 3)

    • Root cause: Timestamp comparison included time, causing off-by-one errors
    • Solution: Normalize both today and startDate to midnight before comparison
    • Applied fix in both useEffect (selectedDay) and render (isToday/isPast)
  2. Fixed duplicate day numbers after Adjust Plan (Day 1, Day 1, Day 2...)

    • Root cause: replanBasedOnProgress merged old days with new plan
    • New plan's days were numbered 1, 2, 3... instead of continuing
    • Solution: Renumber newPlan.dailyPlans to continue from daysPassed + 1
    • Example: If daysPassed=2, new days become Day 3, Day 4, Day 5...
  3. Updated plan title to be dynamic

    • Changed "Your 40-Day Study Plan" to "Your {totalDays}-Day Study Plan"
    • Now correctly shows "Your 30-Day Study Plan" for custom durations

Technical Details:

  • setHours(0, 0, 0, 0) normalizes dates to midnight
  • This ensures Day 3 is selected on the 3rd calendar day regardless of time
  • Fixed in 3 places: useEffect, render calculation, replanBasedOnProgress

Bug Fixes:
1. Fixed wrong day selection (e.g., Day 2 highlighted instead of Day 3)
   - Root cause: Timestamp comparison included time, causing off-by-one errors
   - Solution: Normalize both today and startDate to midnight before comparison
   - Applied fix in both useEffect (selectedDay) and render (isToday/isPast)

2. Fixed duplicate day numbers after Adjust Plan (Day 1, Day 1, Day 2...)
   - Root cause: replanBasedOnProgress merged old days with new plan
   - New plan's days were numbered 1, 2, 3... instead of continuing
   - Solution: Renumber newPlan.dailyPlans to continue from daysPassed + 1
   - Example: If daysPassed=2, new days become Day 3, Day 4, Day 5...

3. Updated plan title to be dynamic
   - Changed "Your 40-Day Study Plan" to "Your {totalDays}-Day Study Plan"
   - Now correctly shows "Your 30-Day Study Plan" for custom durations

Technical Details:
- setHours(0, 0, 0, 0) normalizes dates to midnight
- This ensures Day 3 is selected on the 3rd calendar day regardless of time
- Fixed in 3 places: useEffect, render calculation, replanBasedOnProgress
@vercel

vercel Bot commented Nov 19, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
dashboard Ready Ready Preview Comment Nov 19, 2025 5:51am

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