calculating days Left between two dates excluding national Holidays in jquery UI datepicker -
I need to hide and exclude weekdays (Saturn, Sun) and calculate between two dates, the jQuery UI Use datepicker.
I have been able to calculate the remaining days except weekdays, but it is over now except national holidays. How to exclude these national vacations while calculating the rest of the day
Here is the code:
var natDays = []; Net Day [0] = [1, 27]; Net Day [1] = [2, 6]; Net Day [2] = [3, 17]; Net Day [3] = [2, 7]; Function National Day (date) {for (i = 0; i & lt; natDays.length; i ++) {if (date.getMonth () == Net day [i] [0] - 1 & amp; amp ; And date.getDate () = = net day [ii] [1]) {return [wrong, net day [i] [2] + 'dd']; }} Return [true, '']; } Function not whitened or holidays (date) {var novakend = $. Noxide (date); If (novicend [0]) {return national day (date); } And {return no. }} Exclude the Work Icons and Holidays (StartDate, End Date) {If (Enddate & lieutenant; Startdate) {Return 0; } // Calculate the days between the dates var milliseconds on the left = 86400 * 1000; Start day in // millisecond.Setshors (0,0,0,1); // Just start at midnight and just start. Sethorse (23, 59, 59, 99); // End before midnight diff = endDate - startDate; // Miliseconds between days of objects during day time = Math.ceil (diff / millisecondsPerDay); // Weeks for each week decrease by two weeks of week = mathematics. Floor (day / 7); Var day = day - (week * 2); // Start handle in special cases startDay = startDate.getDay (); Var endDay = endDate.getDay (); // Remove weekends not removed first (if startDay - endDay> 1) day = day - 2; // Start on Sunday starting on Sunday, but if it ends before Saturday, if (startDay == 0 and end day! = 6) day = day - 1 // remove expiration day, if it ends tomorrow evening But starts after Sunday (if the end day == 6 and start! = 0) day = day - 1 // If the national holiday is between two dates (NoviCourse or holidays (date) [0] ) {Days = national day (date); } On the return day; Any help would be appreciated!
In addition, I am trying the following code:
diff = end-date-startDate; Var Holi = New Array ("02-25-2013", "05-22-2013", "06-28-2013"); P = 0; Hcnt = 0; While (P & LT; Holi lamps) {Holiday = New Date (Holy [P]); // warning (leave); If (diff> Holidays-startDate) hcnt ++; // warning (hcnt); P ++; } Returning "Invalid date" error is returning. HCNT is always showing 0.
Try this:
New date ("YYYY-MM- DD "); var holly = new array ( in your case
< P> "MM-DD-YYYY" instead of "... 2013-02-25", "2013-05-22", "2013-06-28");
Comments
Post a Comment