diff --git a/src/components/AirDateBadge/index.tsx b/src/components/AirDateBadge/index.tsx index c626aad97..63c71f086 100644 --- a/src/components/AirDateBadge/index.tsx +++ b/src/components/AirDateBadge/index.tsx @@ -15,7 +15,9 @@ const AirDateBadge = ({ airDate }: AirDateBadgeProps) => { const intl = useIntl(); const dAirDate = new Date(airDate); const nowDate = new Date(); - const alreadyAired = dAirDate.getTime() < nowDate.getTime(); + const dAirDateOffset = + dAirDate.getTime() - dAirDate.getTimezoneOffset() * -60000; + const alreadyAired = dAirDateOffset < nowDate.getTime(); const compareWeek = new Date( alreadyAired ? Date.now() - WEEK : Date.now() + WEEK @@ -24,12 +26,16 @@ const AirDateBadge = ({ airDate }: AirDateBadgeProps) => { let showRelative = false; if ( - (alreadyAired && dAirDate.getTime() > compareWeek.getTime()) || - (!alreadyAired && dAirDate.getTime() < compareWeek.getTime()) + (alreadyAired && dAirDateOffset > compareWeek.getTime()) || + (!alreadyAired && dAirDateOffset < compareWeek.getTime()) ) { showRelative = true; } + const relativeTime = (dAirDateOffset - Date.now()) / 1000; + + const within24Hours = Math.floor(Math.abs(relativeTime / (60 * 60))) <= 24; + return (