Skip to content

Commit

Permalink
chore: make all event dates fetch from schedule (#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaodiaslobo authored Dec 12, 2023
1 parent 4152abe commit 805da32
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 6 additions & 2 deletions layout/Speakers/components/Schedule/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useState, useEffect } from "react";
import Day from "./Day";
import Table from "./Table";

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

function isAfter(date1, date2) {
// equivalent to date1 > date2
const arr1 = date1.split("/");
Expand Down Expand Up @@ -61,8 +63,10 @@ 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];

//calculate default date
const _today = new Date();
Expand Down
11 changes: 9 additions & 2 deletions layout/shared/Leaderboard/Leaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import ErrorMessage from "@components/ErrorMessage";

import { getLeaderboard } from "@lib/api";

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

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

function Leaderboard() {
const min_date = "2023/02/14";
const max_date = "2023/02/17";
/* Fetch first and last day of the event from schedule data */
const eventDates = scheduleData.map((day) => day.date).sort();
const min_date = dayjs(eventDates[0]).format("YYYY/MM/DD");
const max_date = dayjs(eventDates[eventDates.length - 1]).format(
"YYYY/MM/DD"
);

const _today = new Date().toISOString().split("T")[0];
const today = _today.replace(/-/g, "/");
Expand Down

0 comments on commit 805da32

Please sign in to comment.