Date.prototype.addBizDays = function(n){
var day = this.getDay();
var d = new Date();
var wkn = (n < 0 ? -2 : 2);
d.setDate(this.getDate()+n+(day === 6 ? 2 : +!day) +(Math.floor((Math.abs(n)/5))*wkn));
return d;
}
Refactorings
No refactoring yet !
The function add or substracts business days to a date, you use like this
var date = new Date();
date = date.addBizDays(10);