Skip to content

Fix: Incorrect month display in Month view due to day-of-month comparison#600

Open
srihamat wants to merge 1 commit intofrappe:masterfrom
srihamat:fix-month-view-date-calculation
Open

Fix: Incorrect month display in Month view due to day-of-month comparison#600
srihamat wants to merge 1 commit intofrappe:masterfrom
srihamat:fix-month-view-date-calculation

Conversation

@srihamat
Copy link
Copy Markdown

@srihamat srihamat commented Feb 7, 2026

Description:

Problem

Tasks in Month view are incorrectly positioned 1 month earlier when the task's end date day-of-month is less than the Gantt chart's start date day-of-month.

Example:

  • Task: 2026-02-18 → 2026-03-02
  • Expected: Display in March
  • Actual (buggy): Display in February

Root Cause

The diff() function in date_utils.js applies a day-of-month comparison (if (date_a.getDate() < date_b.getDate())) that incorrectly adjusts month calculations used for positioning in Month view.

Solution

  • Separate month-scale calculations from day-scale calculations
  • For month/year scales: Use pure year/month arithmetic
  • For other scales: Keep fractional day-based adjustments

Testing

  • ✅ Month view: Tasks display in correct month
  • ✅ Day/Week views: No regression, still work correctly
  • ✅ Backward compatible: Doesn't break existing functionality

Changes

  • Modified diff() function in src/date_utils.js (lines 126-169)
  • Added conditional logic to skip day-of-month adjustment for month-scale calculations

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.

1 participant