Fix off-by-one date display for UTC-negative timezone users

beginningOfDay() used local timezone methods (getFullYear, getMonth,
getDate) to snap timestamps to midnight. Since the server sends UTC
timestamps, this caused day boundary calculations to be off by one
for users in UTC-negative timezones — cards created after UTC midnight
but before local midnight showed as "yesterday" instead of "today".

Switch to UTC methods (getUTCFullYear, getUTCMonth, getUTCDate) so day
boundaries are calculated consistently with the server's UTC timestamps.

Affects DaysAgoFormatter, DaysAgoOrWeekdayFormatter, TimeOrDateFormatter,
InDaysFormatter, and bubble controller stalled/entropy calculations.
This commit is contained in:
Donal McBreen
2026-04-03 08:21:29 +01:00
parent 7ab6b43e04
commit c2d693fc9a
+1 -1
View File
@@ -7,7 +7,7 @@ export function signedDifferenceInDays(fromDate, toDate) {
}
export function beginningOfDay(date) {
return new Date(date.getFullYear(), date.getMonth(), date.getDate())
return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()))
}
export function secondsToDate(seconds) {