如何从总天数中排除假期?
如何根据美国日历获得公众假期?
<script>
function labourcostcalc() {
var date1 = $('#CostMaster_labour_allocationdate').val();
var date2 = $('#CostMaster_labour_deallocationdate').val();
var diff;
if (date1 >= date2) {
diff = new Date(Date.parse(date1) - Date.parse(date2));
} else if (date1 < date2) {
diff = new Date(Date.parse(date2) - Date.parse(date1));
}
alert('Diff date ' + diff);
var days = diff / 1000 / 60 / 60 / 24;
alert(days);
}
</script>
答案 0 :(得分:1)
您需要在某处存储此假期或查询为您提供该信息的公共服务。您可以使用ajax
保存数据库中的日期列表和查询(计数),而不是按范围$.get('/yourservice/getdates',{begin: date1, end: date2}, function(holidaysCount) {
days -= holidaysCount;
});
在您的服务器中,您需要创建一个表和这样的查询
select count(1) from holidays where holiday_date between :date1 and :date2