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: ( ), }