根据问题,我想根据给定的天数找到未来的日期。它应该排除存储为数组的周末和节假日。下面有此代码但不起作用。
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);