From e41c7009d00a856e99362855d622d6f03a6f1074 Mon Sep 17 00:00:00 2001 From: "MSI\\2Fi" Date: Thu, 2 Jan 2025 14:34:00 +0800 Subject: [PATCH] Update holiday lists, to include last year to avoid missing last year holiday when inputing timesheet that has current year and last year --- src/app/utils/holidayUtils.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/utils/holidayUtils.ts b/src/app/utils/holidayUtils.ts index 30b0e52..c0a14d1 100644 --- a/src/app/utils/holidayUtils.ts +++ b/src/app/utils/holidayUtils.ts @@ -13,7 +13,8 @@ export const getPublicHolidaysForNYears = (years: number = 1, currYr?: number) = .fill(undefined) .flatMap((_, index) => { const currentYear = currYr ?? new Date().getFullYear(); - const holidays = hd.getHolidays(currentYear + index); + const holidays = hd.getHolidays(currentYear - index); + console.log(holidays) return holidays.map((ele) => { const tempDay = new Date(ele.date); const tempYear = tempDay.getFullYear(); @@ -66,7 +67,7 @@ export const getHolidayForDate = ( INPUT_DATE_FORMAT, ), })) - .concat(getPublicHolidaysForNYears(1).concat()); + .concat(getPublicHolidaysForNYears(2).concat()); return currentYearHolidays.find((h) => h.date === date); };