from.setDate(from.getDate()-(sDayofWeek%7))
workdays-=((sDayofWeek-2)>0)?sDayofWeek-2:0
应该改成
//修正到星期六之后,再修正多出来的非假日
if(sDayofWeek >1 &&sDayofWeek <7)
{
from.setDate(from.getDate()-(sDayofWeek%7))
workdays-=((sDayofWeek-2)>0)?sDayofWeek-2:0
}
for(var i=firsti<=last,i+=24*3600*1000){var d = new Date(i)
if(d.getDay() >= 1 &&d.getDay() <= 5){
count++
}
}