diff --git a/page/src/components/CalendarGrid/CalendarGrid.js b/page/src/components/CalendarGrid/CalendarGrid.js index a4b610d0e0..1de5536920 100644 --- a/page/src/components/CalendarGrid/CalendarGrid.js +++ b/page/src/components/CalendarGrid/CalendarGrid.js @@ -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, diff --git a/page/src/components/CalendarGrid/CalendarGrid.utils.js b/page/src/components/CalendarGrid/CalendarGrid.utils.js index f0f2b9a098..165831c9c6 100644 --- a/page/src/components/CalendarGrid/CalendarGrid.utils.js +++ b/page/src/components/CalendarGrid/CalendarGrid.utils.js @@ -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)); } } diff --git a/tools/mdParser.js b/tools/mdParser.js index a1d0de1bd5..92e30b8f9e 100644 --- a/tools/mdParser.js +++ b/tools/mdParser.js @@ -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)" ) => @@ -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 {}; @@ -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=")