diff --git a/src/utils/parse-dining.ts b/src/utils/parse-dining.ts index ed8739d..db9af53 100644 --- a/src/utils/parse-dining.ts +++ b/src/utils/parse-dining.ts @@ -51,9 +51,11 @@ async function ParseXlsx(path: string, year: number): Promise Dinner: menu.getRows(38, 11).map(row => row.values) as xl.CellValue[][] } - const firstDate = menu.getCell(2, 2).value as string; - const startString = firstDate.trim().replace(/(\d)((rd)|(st)|(th)|(nd))/g, "$1") + ` ${year}`; - const startTimestamp = Date.parse(startString); + let firstDate = menu.getCell(2, 2).value as string; + firstDate = firstDate.trim().replace(/(\d)((rd)|(st)|(th)|(nd))/g, "$1"); + firstDate = /(\d{1,2})-?([A-Za-z]+)/.exec(firstDate).slice(1, 3).join("-") + ` ${year}`; + console.log(firstDate); + const startTimestamp = Date.parse(firstDate); if (Number.isNaN(startTimestamp)) { throw new Error("Invalid date");