This is a followup to a previous question about Datepicker. Trying to show only every third day on the calendar. figured out how to get DOY as integer and use in calendar, however it fails every March - also not able to span two years?
On a second part, if I need to disable a certain day of the week, how do I combine that with current 3rd day feature.
here is JSFiddle DatePicker
function noWeekEnds(date) {
var dow = date.getDay();
if(dow>5 || dow<1) return [false,''];
return [true,''];
}
function unavailable(date) {
var now = date;
var start = new Date(now.getFullYear(), 0, 0);
var diff = now - start;
var oneDay = 1000 * 60 * 60 * 24;
var day = Math.floor(diff / oneDay);
var shift = (day%3===0);
return [shift, "red2", "available"];
return noWeekEnds(date);
/*
need this to span across 2 years i.e.: Jan 8 2015 thru Jan 12/2016
also it fails the 3rd week of every March ???
*/
}
$(document).ready(function() {
$("#datepicker").datepicker({
beforeShowDay: unavailable
});
$('#datepicker').attr('readonly',true);
});
return noWeekEnds(date);
will never work as this function ends on first return. – Zentoaku