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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user