I have the following piece of Javascript in that display a future date. Is there a way i can specify a list of days (WET) for it to not land on? So for example, if the date lands on Christmas, have it automatically + 1 (providing it's still a business day and not another holiday)?
Here's what I'm working with:
function addDates(startDate,noOfDaysToAdd){
var 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)
count++;
}
}
return startDate;
}
function convertDate(d) {
function pad(s) { return (s < 10) ? '0' + s : s; }
return [pad(d.getDate()), pad(d.getMonth()+1), d.getFullYear()].join('/');
}
var today = new Date();
var daysToAdd = 6;
var endDate = addDates(today,daysToAdd);
document.write(convertDate(endDate));