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
This commit is contained in:
fallenbagel
2025-02-24 05:35:12 +08:00
committed by GitHub
parent f0a6055774
commit a790b1abcc

View File

@@ -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,
})}
</Badge>
{showRelative && (