Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #919 from prezly/feature/care-4368-embargo-dispaly…
Browse files Browse the repository at this point in the history
…-inconsistent-between-campaign-and-story

[CARE-4368] Display embargo timezone as UTC offset
  • Loading branch information
kudlajz authored Mar 26, 2024
2 parents 6d58be4 + 8545c47 commit db6971a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions modules/Story/Embargo/Embargo.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Culture } from '@prezly/sdk';
import type { EmbargoStory } from '@prezly/theme-kit-core';
import { translations } from '@prezly/theme-kit-intl';
import { FormattedDate, FormattedMessage, FormattedTime } from 'react-intl';
Expand All @@ -10,6 +11,7 @@ type Props = {

function Embargo({ story }: Props) {
const { timezone } = story.newsroom;
const date = new Date(story.published_at);

return (
<div className={styles.embargo}>
Expand All @@ -19,19 +21,25 @@ function Embargo({ story }: Props) {
date: (
<>
<FormattedDate
value={new Date(story.published_at)}
value={date}
year="numeric"
month="long"
day="numeric"
timeZone={timezone}
/>{' '}
<FormattedTime
value={new Date(story.published_at)}
value={date}
hour="2-digit"
minute="2-digit"
timeZoneName="short"
timeZone={timezone}
/>
/>{' '}
UTC
{date
.toLocaleString(Culture.isoCode(story.culture.code), {
timeZoneName: 'longOffset',
timeZone: timezone,
})
.replace(/^.*? GMT/, '')}
</>
),
}}
Expand Down

0 comments on commit db6971a

Please sign in to comment.