Skip to content

Commit

Permalink
fix: #434 (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
scraly authored Apr 24, 2023
1 parent 0c0c6dc commit 23bfc10
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
4 changes: 2 additions & 2 deletions page/src/components/CalendarGrid/CalendarGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const CalendarGrid = ({year}) => {
for (let m = 0; m < 12; m++) {
let days = [];
// Iterate days
let startDate = new Date(year, m);
let endDate = new Date(year, m + 1);
let startDate = new Date(Date.UTC(year, m));
let endDate = new Date(Date.UTC(year, m + 1));
for (const dayDate of DayRange(startDate, endDate)) {
days.push({
date: dayDate,
Expand Down
2 changes: 1 addition & 1 deletion page/src/components/CalendarGrid/CalendarGrid.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import allEvents from 'misc/all-events.json';
export const getEventsOnDate = date => {
let events = [];
for (const event of allEvents) {
if (date >= event.date[0] && date < (event.date[1] ?? event.date[0])) {
if (date >= event.date[0] && date <= (event.date[1] ?? event.date[0])) {
events.push(Object.assign({}, event));
}
}
Expand Down
21 changes: 7 additions & 14 deletions tools/mdParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const MONTHS_NAMES =
);
const MONTHS_SHORTNAMES = MONTHS_NAMES.map((m) => m.slice(0, 3));

const getTimeStamp = (year,month,day) => new Date(Date.UTC(year,month,day,0,0,0)).getTime()

const extractArchiveFiles = (
markdown //eg: " * [2017](archives/2017.md)"
) =>
Expand Down Expand Up @@ -89,26 +91,17 @@ const extractEvents = (monthMarkdown, year, month) =>
const getTimeSpan = (year, month, datespan) => {
const [startDay, endDay] = datespan.split("-").map((d) => d.trim());
if (!endDay) {
return [new Date(year, month, +startDay, 0, 0, 0).getTime()];
return [ getTimeStamp(year,month,+startDay) ]
}
if (endDay.includes("/")) {
//event ends next month "31-02/04"
return [
new Date(year, month, +startDay, 0, 0, 0).getTime(),
new Date(year, month + 1, +endDay.split("/")[0], 0, 0, 0).getTime(),
];
return [ getTimeStamp(year,month,+startDay), getTimeStamp(year,month+1,+endDay.split('/')[0])]
}
if (+startDay > +endDay) {
//event ends next month "31-02"
return [
new Date(year, month, +startDay, 0, 0, 0).getTime(),
new Date(year, month + 1, +endDay, 0, 0, 0).getTime(),
];
return [ getTimeStamp(year,month,+startDay), getTimeStamp(year,month+1,+endDay)]
}
return [
new Date(year, month, +startDay, 0, 0, 0).getTime(),
new Date(year, month, +endDay, 0, 0, 0).getTime(),
];
return [ getTimeStamp(year,month,+startDay), getTimeStamp(year,month,+endDay,0,0,0)]
};
const extractCfp = (shieldCode) => {
if (!shieldCode.includes("shields.io")) return {};
Expand All @@ -127,7 +120,7 @@ const extractCfp = (shieldCode) => {
const monthStr = untilStr.replaceAll(/[^a-zA-Z]/g, "");
const month = MONTHS_SHORTNAMES.indexOf(monthStr.slice(0, 3).toLowerCase());
const day = untilStr.replaceAll(/^\D*(\d{1,2}).*$/g, "$1");
const untilDate = new Date(year, month, day, 0, 0, 0).getTime();
const untilDate = getTimeStamp(year, month, day)

return {
link: shieldCode.includes("href=")
Expand Down

0 comments on commit 23bfc10

Please sign in to comment.