From a790b1abccfa9c3f8272ade8cd055017905dd87f Mon Sep 17 00:00:00 2001 From: fallenbagel <98979876+fallenbagel@users.noreply.github.com> Date: Mon, 24 Feb 2025 05:35:12 +0800 Subject: [PATCH] feat(airdatebadge): convert airDate from UTC to local timezone (#1390) This PR will ensure that the airdate is in the user's local timezone so that its more user friendly and the relative time calculation would be consistent fix #1373 --- src/components/AirDateBadge/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/AirDateBadge/index.tsx b/src/components/AirDateBadge/index.tsx index d4e438a6e..a51f39fc3 100644 --- a/src/components/AirDateBadge/index.tsx +++ b/src/components/AirDateBadge/index.tsx @@ -14,6 +14,7 @@ type AirDateBadgeProps = { const AirDateBadge = ({ airDate }: AirDateBadgeProps) => { const WEEK = 1000 * 60 * 60 * 24 * 8; const intl = useIntl(); + const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone; const dAirDate = new Date(airDate); const nowDate = new Date(); const alreadyAired = dAirDate.getTime() < nowDate.getTime(); @@ -38,7 +39,7 @@ const AirDateBadge = ({ airDate }: AirDateBadgeProps) => { year: 'numeric', month: 'long', day: 'numeric', - timeZone: 'UTC', + timeZone, })} {showRelative && (