4
繼從this question其計算指定日期範圍內特定的工作日數:計算具體平日使用這種排除假期在Javascript
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);
}
我想也知道假期怎麼能如果在星期幾的範圍內,假設我在d0
和d1
之間發生了一系列假期,那麼排除它們。
感謝幫助!