From 8394eb5ad405a90e840952d5977712e1ab890530 Mon Sep 17 00:00:00 2001 From: fallenbagel <98979876+fallenbagel@users.noreply.github.com> Date: Sat, 15 Mar 2025 03:49:54 +0800 Subject: [PATCH] revert(airdate): reverts airdate offset & changes relative time to only display date (not time) (#1467) * revert(airdate): reverts airdate offset and changes relative time to only display date (not time) This reverts #1390 as it created more confusion when we offsetted the air date in relevance to the timezone. It also changes the relative time to use date instead of time (so it will say `aired yesterday` `today` `5 days ago` instead of `aired x hours ago` since we dont really the airtime data. * fix: relate time in days instead of hours * fix: relative time in days * fix: relative time in days (but properly) --- src/components/AirDateBadge/index.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/AirDateBadge/index.tsx b/src/components/AirDateBadge/index.tsx index a51f39fc3..1143c3e3e 100644 --- a/src/components/AirDateBadge/index.tsx +++ b/src/components/AirDateBadge/index.tsx @@ -14,17 +14,13 @@ 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(); - const compareWeek = new Date( alreadyAired ? Date.now() - WEEK : Date.now() + WEEK ); - let showRelative = false; - if ( (alreadyAired && dAirDate.getTime() > compareWeek.getTime()) || (!alreadyAired && dAirDate.getTime() < compareWeek.getTime()) @@ -32,6 +28,10 @@ const AirDateBadge = ({ airDate }: AirDateBadgeProps) => { showRelative = true; } + const diffInDays = Math.round( + (dAirDate.getTime() - nowDate.getTime()) / (1000 * 60 * 60 * 24) + ); + return (
@@ -39,7 +39,7 @@ const AirDateBadge = ({ airDate }: AirDateBadgeProps) => { year: 'numeric', month: 'long', day: 'numeric', - timeZone, + timeZone: 'UTC', })} {showRelative && ( @@ -49,9 +49,9 @@ const AirDateBadge = ({ airDate }: AirDateBadgeProps) => { { relativeTime: ( ), }