Following on from this question which calculates the number of specific weekdays in a given date range using this:
function countCertainDays( days, d0, d1 ) {
var ndays = 1 + Math.round((d1-d0)/(24*3600*1000));
var sum = function(a,b) {
return a + Math.floor( ( ndays + (d0.getDay()+6-b) % 7 ) / 7 );
};
return days.reduce(sum,0);
}
I'd like to also know how holidays can be excluded if they fall on the weekday in the range, assuming I have an array of holidays occurring between d0
and d1
.
Appreciate the help!