As per question, I would like to find the future date based on a given number of days. It should exclude weekends and holidays that is stored as array. Have this code below but the future date generated is incorrect. Any suggestions?
var holiday = [];
holiday[0] = new Date(2013, 11, 12);
holiday[1] = new Date(2013, 11, 13);
var startDate = new Date();
var endDate = "", noOfDaysToAdd = 13, count = 0;
while (count < noOfDaysToAdd) {
endDate = new Date(startDate.setDate(startDate.getDate() + 1));
if (endDate.getDay() != 0 && endDate.getDay() != 6) {
// Date.getDay() gives weekday starting from 0(Sunday) to
// 6(Saturday)
for ( var i = 0; i < holiday.length; i++) {
if (endDate != holiday[i]) { //If days are not holidays
count++;
}
}
}
}
alert(endDate);