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

feat: fetch event dates from schedule data #594

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 7 additions & 2 deletions components/Schedule/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Day from "./Day";
import { useState, useEffect } from "react";
import { useRouter } from "next/router";

import scheduleData from "/data/schedule.json";

function leapYear(year) {
return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
}
Expand Down Expand Up @@ -87,8 +89,11 @@ function addDate(date, days) {
}

export default function Schedule(props) {
const min_date = "2023/2/14";
const max_date = "2023/2/17";
/* Fetch first and last day of the event from schedule data */
const eventDates = scheduleData.map((day) => day.date).sort();
const min_date = eventDates[0];
const max_date = eventDates[eventDates.length - 1];

const defaultFilter = props.filters === undefined ? "" : props.filters;

//calculate default date
Expand Down
19 changes: 18 additions & 1 deletion layout/Home/components/Hero/Title/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
import TypeWriter from "typewriter-effect";
import schedule from "@data/schedule.json";

export default function Title() {
/* Parse event dates info from schedule data */
const dates = schedule.map((day) => day.date).sort();
const firstDayData = dates[0].split("/");

/* Parse year */
const year = firstDayData[0];

/* Parse month */
const month = new Intl.DateTimeFormat("en-US", { month: "long" }).format(
new Date().setMonth(parseInt(firstDayData[1]) - 1)
);

/* Parse first and last day of the event */
const firstDay = firstDayData.pop();
const lastDay = dates.pop().split("/").pop();

return (
<div className="relative z-20 font-bold">
<h5 className="font-terminal-uppercase m-1 text-2xl text-quinary">
14-17 February 2023
{firstDay}-{lastDay} {month} {year}
joaodiaslobo marked this conversation as resolved.
Show resolved Hide resolved
</h5>
{/* 2xl:leading-[6.5rem] is intended to only work with the following font - Terminal */}
<h1
Expand Down
Loading