SHARE
TWEET

Untitled

a guest Jul 17th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     var DateUtils = {
  2.  
  3.         daysBetween: function (start, end) {
  4.             if (!start || !end) { return 0; }
  5.             start = Date.parse(start); end = Date.parse(end);
  6.             if (start.getYear() == 1901 || end.getYear() == 8099) { return 0; }
  7.             var count = 0, date = start.clone();
  8.             while (date.compareTo(end) == -1) { count = count + 1; date.addDays(1); }
  9.             return count;
  10.         },
  11.    
  12.     businessdays: function(dDate1, dDate2) {
  13.         var d = DateUtils.daysBetween(dDate1,dDate2);
  14.         var t= d%7;
  15.  
  16.         if (dDate1 < dDate2) {
  17.             w1 = dDate1.getDay();
  18.             w2 = dDate2.getDay();
  19.         }
  20.         else {
  21.             w2 = dDate1.getDay();
  22.             w1 = dDate2.getDay();
  23.         }
  24.  
  25.         if (w1 > w2) {
  26.             t -= 2;
  27.         }
  28.         if (w1 == 0 && w2 == 6) {
  29.             t--;
  30.         }
  31.         return Math.abs((Math.floor(d / 7) * 5) + t);
  32.        
  33.     }
  34.     };
RAW Paste Data
Top