Skip to content

Commit

Permalink
refactor: put endTime inside date object
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenixpereira committed Mar 18, 2024
1 parent 9f8b26e commit 5f452c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
5 changes: 2 additions & 3 deletions src/app/events/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,15 @@ export default function Events({ className }: { className?: string }) {
// Convert event date and check if upcoming event
const upcomingEvents = EVENTS.filter((event) => {
const eventDate = new Date(
`${event.date.year} ${event.date.month} ${event.date.day} ${event.endTime}`
`${event.date.year} ${event.date.month} ${event.date.day} ${event.date.endTime}`
);
console.log('event: ' + eventDate);
return eventDate >= currentDate;
});

// Convert event date, check if past event and reverse events
const pastEvents = EVENTS.filter((event) => {
const eventDate = new Date(
`${event.date.year} ${event.date.month} ${event.date.day} ${event.endTime}`
`${event.date.year} ${event.date.month} ${event.date.day} ${event.date.endTime}`
);
return eventDate < currentDate;
}).reverse();
Expand Down
18 changes: 6 additions & 12 deletions src/data/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ type Month =
| 'DEC';
export type Event = {
title: string;
date: { year: number; month: Month; day: number };
endTime: string;
date: { year: number; month: Month; day: number; endTime: string };
time: string;
location: string;
details: string;
Expand All @@ -26,8 +25,7 @@ export type Event = {
export const EVENTS: Event[] = [
{
title: 'Meet and Greet',
date: { year: 2024, month: 'MAR', day: 1 },
endTime: '21:00',
date: { year: 2024, month: 'MAR', day: 1, endTime: '21:00' },
time: '5:00pm - 9:00pm',
location: 'Engineering and Maths EM105',
details:
Expand All @@ -36,8 +34,7 @@ export const EVENTS: Event[] = [
},
{
title: 'Insight Into Industry',
date: { year: 2024, month: 'MAR', day: 6 },
endTime: '21:00',
date: { year: 2024, month: 'MAR', day: 6, endTime: '21:00' },
time: '6:00pm - 9:00pm',
location: 'Ingkarni Wardli 715',
details:
Expand All @@ -46,26 +43,23 @@ export const EVENTS: Event[] = [
},
{
title: 'Quiz Night',
date: { year: 2024, month: 'MAR', day: 8 },
endTime: '21:00',
date: { year: 2024, month: 'MAR', day: 8, endTime: '21:00' },
time: '6:00pm - 9:00pm',
location: 'Ingkarni Wardli 218',
details: 'Join us for a night of quizzical encounters! Free food and prizes to come!',
image: 'quiz-night.jpg',
},
{
title: 'Industry Night',
date: { year: 2024, month: 'APR', day: 2 },
endTime: '21:00',
date: { year: 2024, month: 'APR', day: 2, endTime: '21:00' },
time: '6:00pm - 9:00pm',
location: 'The National Wine Centre, Hickinbotham Hall',
details: 'Connect with top companies and explore job opportunities in the tech industry!',
image: 'industry-night.jpg',
},
{
title: 'LaTeX Workshop',
date: { year: 2024, month: 'APR', day: 4 },
endTime: '19:00',
date: { year: 2024, month: 'APR', day: 4, endTime: '19:00' },
time: '5:00pm - 7:00pm',
location: 'Ingkarni Wardli 218',
details:
Expand Down

0 comments on commit 5f452c1

Please sign in to comment.