function AddBusinessDays(startDate, workDaysToAdd) { var curDate = new Date(startDate); var realDaysToAdd = 0; while (workDaysToAdd > 0) { realDaysToAdd++; if (IsWorkDay(curDate)) { workDaysToAdd--; } curDate.setDate(curDate.getDate() + 1); } return realDaysToAdd; } function IsWorkDay(date) { var curDate = new Date(date); var dayOfWeek = curDate.getDay(); var isWorkDay; if (dayOfWeek === 0 || dayOfWeek === 5) { isWorkDay = false; } else { isWorkDay = !isNationalDay(curDate); } return isWorkDay; } function isNationalDay(date) { var thisDate = new Date(date); var thisMoment = moment(thisDate); var holiday = thisMoment.holiday(); var isHoliday = holiday != 'undefined' && holiday != null && holiday.length > 0; return isHoliday; }
while (workDaysToAdd > 0)
while (workDaysToAdd < 0) { realDaysToAdd--; if (IsWorkDay(curDate)) { workDaysToAdd++; } curDate.setDate(curDate.getDate() - 1); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)