次のコードを試すことができます: get_date() は私のコードで ajax を介して呼び出しています。配列を作成できます。そこに日付を入力します。
window.natDays = [];
$.ajax({
type : "POST",
async : false,
url : rootPath + '/get_date',
data : "ajax=true",
success : function(msg) {
var a = $.parseJSON(msg);
$i = 0;
$.each(a, function(key, value) {
arr = (value.Date['date']).split('-');
arr2[key] = new Array(value.Date['month'], arr[2],
value.Date['occassion']);
});
natDays = arr2;
}
});
var dateMaxforswitch = new Date();
dateMinforswitch.setDate(dateMinforswitch.getDate()
+ (dateMinforswitch.getHours() >= 17 ? 1 : 0));
dateMaxforswitch.setDate(dateMaxforswitch.getDate()
+ (dateMaxforswitch.getHours() >= 17 ? 1 : 0));
AddBusinessDays(dateMaxforswitch, 25);
function AddBusinessDays(curdate, weekDaysToAdd) {
while (weekDaysToAdd > 0) {
curdate.setDate(curdate.getDate() + 1);
// check if current day is business day
if (noWeekendsOrHolidays(curdate)[0]) {
weekDaysToAdd--;
}
}
}
function noWeekendsOrHolidays(date) {
var noWeekend = $.datepicker.noWeekends(date);
if (noWeekend[0]) {
return nationalDays(date);
} else {
return noWeekend;
}
}
function nationalDays(date) {
for (i = 0; i < natDays.length; i++) {// alert(natDays[i][2]);
if (date.getMonth() == natDays[i][0] - 1 && date.getDate() == natDays[i][1]) {
return [ false, natDays[i][2] + '_day' ];
}
}
return [ true, '' ];
}