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:
Marc-André Bombeck committed 2026-10-19 14:56:53 +02:00
1 parent 01bf8fbb64
commit ff3559c169
6 files changed
+72 -12

No files matched your search

+6 -3
View File
@@ -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;
}