From 5f04bc7a688f0ceeb451e16de5b164022de45303 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Mon, 23 Mar 2026 20:21:18 +0200 Subject: [PATCH] Fix timezone parsing error crashing the whole user page --- app/features/user-page/components/Widget.tsx | 50 +++++++++++--------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/app/features/user-page/components/Widget.tsx b/app/features/user-page/components/Widget.tsx index fc12fc8a6..a011261ee 100644 --- a/app/features/user-page/components/Widget.tsx +++ b/app/features/user-page/components/Widget.tsx @@ -25,6 +25,7 @@ import type { StageId, } from "~/modules/in-game-lists/types"; import { databaseTimestampToDate } from "~/utils/dates"; +import { logger } from "~/utils/logger"; import type { SerializeFrom } from "~/utils/remix"; import { assertUnreachable } from "~/utils/types"; import { @@ -530,31 +531,36 @@ function TimezoneWidget({ timezone }: { timezone: string }) { return () => clearInterval(interval); }, []); - const formatter = new Intl.DateTimeFormat("en-US", { - timeZone: timezone, - hour: "numeric", - minute: "2-digit", - second: "2-digit", - hour12: true, - }); + try { + const formatter = new Intl.DateTimeFormat("en-US", { + timeZone: timezone, + hour: "numeric", + minute: "2-digit", + second: "2-digit", + hour12: true, + }); - const dateFormatter = new Intl.DateTimeFormat("en-US", { - timeZone: timezone, - weekday: "short", - day: "numeric", - month: "short", - }); + const dateFormatter = new Intl.DateTimeFormat("en-US", { + timeZone: timezone, + weekday: "short", + day: "numeric", + month: "short", + }); - return ( -
-
- {formatter.format(currentTime)} + return ( +
+
+ {formatter.format(currentTime)} +
+
+ {dateFormatter.format(currentTime)} +
-
- {dateFormatter.format(currentTime)} -
-
- ); + ); + } catch { + logger.warn(`Failed to parse timezone: ${timezone}`); + return null; + } } function FavoriteStageWidget({ stageId }: { stageId: StageId }) {