Hi, I am trying to fetch the next working day of the bank. To find that I am trying the bellow code but the isHoliday() function is not returning me boolean value. but if I use something like holidays.isHoliday(new Date()) in this case it returns true and false.
Here is my method :
import * as DateHolidays from "date-holidays";
const holidays = new DateHolidays.default();
holidays.init("se");
const getNextWorkingDate = () => {
let year = new Date().getFullYear();
let month = new Date().getMonth();
const date = new Date(year, month, 1);
console.log("date >>>>> ", date);
while (date.getMonth() === month) {
const endDate = moment(new Date(date));
if (endDate.diff(new Date(), "days") > 0) {
if (!holidays.isHoliday(new Date(date))) {
let workingDate = new Date(date);
return workingDate;
}
}
date.setDate(date.getDate() + 1);
}
return new Date();
};
Hi, I am trying to fetch the next working day of the bank. To find that I am trying the bellow code but the isHoliday() function is not returning me boolean value. but if I use something like holidays.isHoliday(new Date()) in this case it returns true and false.
Here is my method :
Please let me know how will it work!!
Thanks