Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct date of Adoptium news #2894

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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