mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 23:52:24 +00:00
fix(workouts): render workout dates in the profile timezone
The workout list, the workout header and the dashboard tile formatted instants through the shared formatter cache without a timeZone, so they followed the browser's zone. The year comparison in the list used the browser's calendar as well. All three now take the profile zone, and the timezone guard also matches getDateTimeFormat(locale, options) calls that leave the zone out.
This commit is contained in:
1 parent
01bf8fbb64
commit
ff3559c169
6 files changed
+72
-12
No files matched your search
@@ -124,9 +124,12 @@ function asDate(value: DateInput): Date {
|
||||
* lookup is cheap.
|
||||
*/
|
||||
function isCurrentYearInTz(date: Date, tz: string, localeTag: string): boolean {
|
||||
const yearOnly = { timeZone: tz, year: "numeric" as const };
|
||||
const target = getDateTimeFormat(localeTag, yearOnly).format(date);
|
||||
const now = getDateTimeFormat(localeTag, yearOnly).format(new Date());
|
||||
const yearIn = (value: Date) =>
|
||||
getDateTimeFormat(localeTag, { timeZone: tz, year: "numeric" }).format(
|
||||
value,
|
||||
);
|
||||
const target = yearIn(date);
|
||||
const now = yearIn(new Date());
|
||||
return target === now;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user