Skip to content

Instantly share code, notes, and snippets.

@ethyde
Created September 30, 2014 11:17
Show Gist options
  • Save ethyde/5d0df47141c740ecf828 to your computer and use it in GitHub Desktop.
Save ethyde/5d0df47141c740ecf828 to your computer and use it in GitHub Desktop.
$("input").datepicker({
beforeShowDay: nonWorkingDates,
numberOfMonths: 1,
minDate: '05/01/14',
firstDay: 1
});
function nonWorkingDates(date){
var day = date.getDay(), Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6;
var closedDates = [[7,25, 2014], [8, 14, 2014]];
var closedDays = [[Monday], [Tuesday]];
for (var i = 0; i < closedDays.length; i++) {
if (day == closedDays[i][0]) {
return [false];
}
}
for (i = 0; i < closedDates.length; i++) {
if (date.getMonth() == closedDates[i][0] - 1 &&
date.getDate() == closedDates[i][1] &&
date.getFullYear() == closedDates[i][2]) {
return [false];
}
}
return [true];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment