Skip to content

Commit 5e4deee

Browse files
committed
added helper for holiday normalization
1 parent 5fd9353 commit 5e4deee

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

js/jquery.fn.gantt.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,19 +1638,22 @@
16381638
}
16391639
},
16401640

1641+
// normalizes an array of dates into a map of start-of-day millisecond values
1642+
_datesToDays: function ( dates ) {
1643+
var dayMap = {};
1644+
for (var i = 0, len = dates.length, day; i < len; i++) {
1645+
day = tools.dateDeserialize( dates[i] );
1646+
dayMap[ day.setHours(0, 0, 0, 0) ] = true;
1647+
}
1648+
return dayMap;
1649+
},
16411650
// Returns true when the given date appears in the array of holidays, if provided
1642-
//TODO: test this! -UA
16431651
isHoliday: (function() { // IIFE
16441652
// short-circuits the function if no holidays option was passed
16451653
if (!settings.holidays) {
16461654
return function () { return false; };
16471655
}
1648-
// normalizes holidays into millisecond values (limiting scope to just this function)
1649-
var holidays = {};
1650-
for (var i = 0, h = settings.holidays, len = h.length, day; i < len; i++) {
1651-
day = dateDeserialize( h[i] );
1652-
holidays[ day.setHours(0, 0, 0, 0) ] = true;
1653-
}
1656+
var holidays = tools._datesToDays( settings.holidays );
16541657
// returns the function that will be used to check for holidayness of a given date
16551658
return function(date) {
16561659
return !!holidays[

0 commit comments

Comments
 (0)