Skip to content

Commit

Permalink
Correct date of Adoptium news (#2894)
Browse files Browse the repository at this point in the history
* Correct date of AdoptiumNews

* Ensure UTC

* Add timeZone: "UTC"
  • Loading branch information
xavierfacq authored Jun 1, 2024
1 parent a5c13a7 commit ba578bd
Showing 1 changed file with 33 additions and 14 deletions.
47 changes: 33 additions & 14 deletions src/components/AdoptiumNews/index.tsx
Original file line number Diff line number Diff line change
@@ -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 <callToActionLink /> 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.<br/>Connect with peers to exchange knowledge on Temurin, AQAvit and other Adoptium's projects.<br/><callToActionLink>Register here</callToActionLink>",
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 <callToActionLink /> 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.<br/>Connect with peers to exchange knowledge on Temurin, AQAvit and other Adoptium's projects.<br/><callToActionLink>Register here</callToActionLink>",
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();
Expand All @@ -26,7 +45,7 @@ const AdoptiumNews = () => {
<div className='container py-5'>
<h2 className='text-pink'>{adoptiumNews.title}</h2>
<div>
{adoptiumNews.date && <p className='m-0 fw-bold'>{moment(adoptiumNews.date).format('D MMMM YYYY')}</p>}
{eventDateUTC && <p className='m-0 fw-bold'>{(eventDateUTC.toLocaleDateString(language, eventDateOptions))}</p>}
<p className='text-muted lh-sm'>
<Trans
defaults={adoptiumNews.body}
Expand Down

0 comments on commit ba578bd

Please sign in to comment.