Skip to content

Commit

Permalink
feat(airdatebadge): convert airDate from UTC to local timezone (#1390)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fallenbagel authored Feb 23, 2025
1 parent f0a6055 commit a790b1a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/AirDateBadge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -38,7 +39,7 @@ const AirDateBadge = ({ airDate }: AirDateBadgeProps) => {
year: 'numeric',
month: 'long',
day: 'numeric',
timeZone: 'UTC',
timeZone,
})}
</Badge>
{showRelative && (
Expand Down

0 comments on commit a790b1a

Please sign in to comment.