diff --git a/src/components/AdoptiumNews/index.tsx b/src/components/AdoptiumNews/index.tsx index 98fcbe7b1..57e95f329 100644 --- a/src/components/AdoptiumNews/index.tsx +++ b/src/components/AdoptiumNews/index.tsx @@ -1,21 +1,40 @@ import React from 'react'; -import moment from 'moment'; -import { Trans } from 'gatsby-plugin-react-i18next'; +import { Trans, useI18next } from 'gatsby-plugin-react-i18next'; import LinkText from '../LinkText' +// NOTES: +// - You can add a tag to create a link in the body +// - Dates must be with the format: "YYYY-MM-dd" +const adoptiumNews = { + title: "Adoptium Summit 2024", + body: "Be a part of the first-ever Adoptium Summit on September, 10.
Connect with peers to exchange knowledge on Temurin, AQAvit and other Adoptium's projects.
Register here", + callToActionLink: 'https://www.eclipse.org/events/2024/adoptium-summit/', + date: new Date('2024-09-10'), + startDisplayAt: new Date('2024-05-15'), + stopDisplayAfter: new Date('2024-06-30'), +} + +const eventDateOptions = { + year: 'numeric', + month: 'long', + day: 'numeric', + timeZone: "UTC" +} + const AdoptiumNews = () => { - // NOTES: - // - You can add a tag to create a link in the body - // - Dates must be with the format: "YYYY-MM-dd" - - const adoptiumNews = { - title: "Adoptium Summit 2024", - body: "Be a part of the first-ever Adoptium Summit on September, 10.
Connect with peers to exchange knowledge on Temurin, AQAvit and other Adoptium's projects.
Register here", - callToActionLink: 'https://www.eclipse.org/events/2024/adoptium-summit/', - date: new Date('2024-09-10'), - startDisplayAt: new Date('2024-05-15'), - stopDisplayAfter: new Date('2024-06-30'), + const { language } = useI18next(); + + var eventDateUTC:Date|null = null; + if(adoptiumNews.date) { + eventDateUTC = new Date(Date.UTC( + adoptiumNews.date.getUTCFullYear(), + adoptiumNews.date.getUTCMonth(), + adoptiumNews.date.getUTCDate(), + adoptiumNews.date.getUTCHours(), + adoptiumNews.date.getUTCMinutes(), + adoptiumNews.date.getUTCSeconds())); + } const now = Date.now(); @@ -26,7 +45,7 @@ const AdoptiumNews = () => {

{adoptiumNews.title}

- {adoptiumNews.date &&

{moment(adoptiumNews.date).format('D MMMM YYYY')}

} + {eventDateUTC &&

{(eventDateUTC.toLocaleDateString(language, eventDateOptions))}

}