-1

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

BarclayVision
  • 865
  • 2
  • 12
  • 41

1 Answers1

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