is it possible to get the DOY in the Datepicker - I need to disable every 3rd day and could use something like date.getDOY() % 3 === 0
Asked
Active
Viewed 193 times
-1

BarclayVision
- 865
- 2
- 12
- 41
-
what do you mean by display every third day? do you want to disable all the other days – Arun P Johny Aug 26 '14 at 01:02
-
http://stackoverflow.com/questions/8619879/javascript-calculate-the-day-of-the-year-1-366 – Arun P Johny Aug 26 '14 at 01:03
-
yes its shift work that occurs like 1/2/2015,1/5/2015,1/8/2015,ext.. – BarclayVision Aug 26 '14 at 01:06
-
http://stackoverflow.com/questions/8619879/javascript-calculate-the-day-of-the-year-1-366 did not help, that determining if leap year 365 or 366 (why the mark down...) – BarclayVision Aug 26 '14 at 01:19
1 Answers
0
The following works until it gets to the next year (Jan 2015) and also fails in 3rd week of March in every year?
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Restrict date range</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
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, "", "Unavailable"];
}
$(document).ready(function() {
$("#datepicker").datepicker({
beforeShowDay: unavailable
});
});
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
</body>
</html>

BarclayVision
- 865
- 2
- 12
- 41