Bug Description
DateUtils.differenceInDays() (line 258-261 in core/calendar/DateUtils.js) uses millisecond arithmetic:
static differenceInDays(date1, date2) {
const diff = date1.getTime() - date2.getTime();
return Math.floor(diff / (1000 * 60 * 60 * 24));
}
This is inconsistent with the rest of the file, which deliberately uses setDate() for date arithmetic to handle DST transitions correctly (see comments on lines 40-41, 56-57, 106-107, 413-414).
Problem
When a DST transition occurs between date1 and date2, the number of milliseconds in a day is 23 or 25 hours instead of 24. This causes differenceInDays to return incorrect results. For example, crossing a "spring forward" boundary could report 0 days difference for dates that are actually 1 day apart.
Expected Fix
Use date-based arithmetic that's immune to DST, similar to the pattern used elsewhere in the file. For example, compare normalized dates (midnight-to-midnight) using setHours(0,0,0,0) before computing the difference.
Files
core/calendar/DateUtils.js:258-261
- Also affects
differenceInWeeks() which delegates to differenceInDays()
Bug Description
DateUtils.differenceInDays()(line 258-261 incore/calendar/DateUtils.js) uses millisecond arithmetic:This is inconsistent with the rest of the file, which deliberately uses
setDate()for date arithmetic to handle DST transitions correctly (see comments on lines 40-41, 56-57, 106-107, 413-414).Problem
When a DST transition occurs between
date1anddate2, the number of milliseconds in a day is 23 or 25 hours instead of 24. This causesdifferenceInDaysto return incorrect results. For example, crossing a "spring forward" boundary could report 0 days difference for dates that are actually 1 day apart.Expected Fix
Use date-based arithmetic that's immune to DST, similar to the pattern used elsewhere in the file. For example, compare normalized dates (midnight-to-midnight) using
setHours(0,0,0,0)before computing the difference.Files
core/calendar/DateUtils.js:258-261differenceInWeeks()which delegates todifferenceInDays()