mirror of
https://github.com/marcogll/AnchorOS.git
synced 2026-03-15 17:24:30 +00:00
Fix critical bug where calendar days were misaligned with weekdays: PROBLEM: - January 1, 2026 showed as Monday instead of Thursday - Calendar grid didn't calculate proper offset for first day of month - Days were placed in grid without accounting for weekday padding ROOT CAUSE: - DatePicker component used eachDayOfInterval() to generate days - Grid cells were populated directly from day 1 without offset calculation - getDay() returns 0-6 (Sunday-Saturday) but calendar header uses Monday-Sunday SOLUTION: - Calculate offset using getDay() of first day of month - Adjust for Monday-start week: offset = dayOfWeek === 0 ? 6 : dayOfWeek - 1 - Add padding cells (empty divs) at start of grid for correct alignment - For January 2026: Thursday (getDay=4) → offset=3 (3 empty cells before day 1) EXAMPLE: - January 1, 2026 is Thursday (getDay=4) - With Monday-start calendar: L M X J V S D - Correct grid: _ _ _ 1 2 3 4 ... (3 empty cells then day 1) This ensures all dates align correctly with their weekday headers.