-1
이 질문은 많은 시간을 요청을받은 것을 알고 있지만, 도와주세요 난 일 더는 제외하고 계산되지 수 있어요 아래의 코드와 솔루션셉 일
을 찾을 수 없습니다입니다 평일
지금 나는 또한 공휴일을 제외 할
는 예를 들어 2012년 8월 15일, 2012년 9월 12일, 2012년 12월 20일를 들어,function namet()
{
var iWeeks, iDateDiff, iAdjust = 0;
var nodays = document.getElementById("timestamp1").value;
var nodays1 = document.getElementById("timestamp").value;
var dDate1 = new Date(nodays1);
var dDate2 = new Date(nodays);
if (dDate2 < dDate1) {
alert("End Date : Enter date more than Start Date ");
}
// error code if dates transposed
var iWeekday1 = dDate1.getDay(); // day of week
var iWeekday2 = dDate2.getDay();
iWeekday1 = (iWeekday1 == 0) ? 7 : iWeekday1; // change Sunday from 0 to 7
iWeekday2 = (iWeekday2 == 0) ? 7 : iWeekday2;
if ((iWeekday1 > 5) && (iWeekday2 > 5)) iAdjust = 1; // adjustment if both days on weekend
iWeekday1 = (iWeekday1 > 5) ? 5 : iWeekday1; // only count weekdays
iWeekday2 = (iWeekday2 > 5) ? 5 : iWeekday2;
// calculate differnece in weeks (1000mS * 60sec * 60min * 24hrs * 7 days = 604800000)
iWeeks = Math.floor((dDate2.getTime() - dDate1.getTime())/604800000)
if (iWeekday1 <= iWeekday2) {
iDateDiff = (iWeeks * 5) + (iWeekday2 - iWeekday1)
} else {
iDateDiff = ((iWeeks + 1) * 5) - (iWeekday1 - iWeekday2)
}
iDateDiff -= iAdjust // take into account both days on weekend
var final = (iDateDiff + 1); // add 1 because dates are inclusive
document.leaveapplication.noofdays3.value = final;
공휴일은 무엇입니까? 지정해야합니다. 나라마다 달라질 수 있습니다. – polin
공휴일은 원칙적으로 주중에 오기 때문에 '주 * 종료 * 및 휴일 제외'를 의미한다고 가정합니다. –
예를 들어 공휴일은 2010 년 8 월 15 일, 2012 년 9 월 20 일, 2012 년 12 월 20 일, 12 월 20 일이며 평일은 토요일과 일요일 제외합니다. – jim