added short timezone code to times

This commit is contained in:
Benjamin Jones 2021-06-01 12:25:16 +02:00
parent 4b1ede7130
commit 94e89276c2
2 changed files with 20 additions and 2 deletions

View File

@ -57,6 +57,19 @@ const Info = ({ data, loading, infoActive, setInfoActive, currentVideo }) => {
)
: []
const dateString = `${new Date()}`
let tzShort =
// Works for the majority of modern browsers
dateString.match(/\(([^\)]+)\)$/) ||
// IE outputs date strings in a different format:
dateString.match(/([A-Z]+) [\d]{4}$/)
if (tzShort) {
// Old Firefox uses the long timezone name (e.g., "Central
// Daylight Time" instead of "CDT")
tzShort = tzShort[1].match(/[A-Z]/g).join('')
}
return (
<InfoLayout loading={loading}>
{embedURL ? (
@ -102,7 +115,11 @@ const Info = ({ data, loading, infoActive, setInfoActive, currentVideo }) => {
<Fragment>
<Title>{translations.en.nextStream}:</Title>
{futureStreams.map(feeditem => (
<VideoCard key={feeditem.start} {...feeditem} />
<VideoCard
key={feeditem.start}
tzShort={tzShort}
{...feeditem}
/>
))}
</Fragment>
) : null}

View File

@ -184,6 +184,7 @@ export const VideoCard = ({
hasPassed,
videoUrl,
onClickButton,
tzShort,
}) => {
const startDate = new Date(start)
const utcDate = zonedTimeToUtc(startDate, 'Europe/Berlin')
@ -197,7 +198,7 @@ export const VideoCard = ({
<Span bold colour={colours.midnight}>
{hasPassed
? format(zonedDate, 'dd/MM/yy')
: format(zonedDate, 'do LLLL y // HH:mm')}
: `${format(zonedDate, 'do LLLL y // HH:mm')} ${tzShort}`}
</Span>
</DateLabel>
{videoUrl && hasPassed ? (