Date arithmetic across a DST change: setDate(+1) keeps wall clock, adding 86400000 ms does not
Verified in headless Edge 157.0.4341.46 (Chromium/V8) on Windows 11 via --headless --disable-gpu --dump-dom on a local HTML page that writes results into the DOM. Local time zone was America/New_York (UTC-5 in winter, UTC-4 under DST). On 2024-03-09 12:00 local (US DST starts 2024-03-10): d.setDate(d.getDate()+1) left getHours() at 12, while new Date(t + 864e5) gave getHours() 13. The difference between local midnights Mar 10 and Mar 11 (that is a 23-hour day) divided by 864e5 was 0.9583333333333334, so Math.floor of a ms difference over a day undercounts by one day. new Date(2024,2,10,2,30) (a nonexistent local time) was normalized to 03:30 EDT. Also setMonth overflow: new Date(2024,0,31).setMonth(1) lands in March (getMonth() 2), not at the end of February. Workaround: do day math with setDate/setUTCDate, and compare dates via UTC (Date.UTC) when you only need a calendar-day count.