title: Elegant method to generate array of random dates within two dates
body: <p>I have a datepicker where I show two months and I want to randomly choose 3 dates in each visible month </p>
  
  <pre><code>  $('.date').datepicker({
      minDate: new Date(),
      dateFormat: 'DD, MM, d, yy',
      constrainInput: true,
      beforeShowDay: processDates,
      numberOfMonths: 2,
      showButtonPanel: true,
      showOn: "button",
      buttonImage: "images/calendar_icon.jpg",
      buttonImageOnly: true    
    });
  </code></pre>
  
  <p>Here is my calculation</p>
  
  <pre><code>var now = new Date();
  var nowTime = parseInt(now.getTime()/1000);
  var randomDateSet = {};
  
  function getRandomSet(y,m) {
    var monthIndex = "m"+y+""+m; // m20121 for Jan
    if (randomDateSet[monthIndex]) return randomDateSet[monthIndex];
    // generate here
  .
  . - I need this part
  .
    return randomDateSet[monthIndex];
  }
  
  function processDay(date) { // this is calculated for each day so we need a singleton for the array
    var dateTime = parseInt(date.getTime()/1000);
    if (dateTime &lt;= (nowTime-86400)) {
      return [false]; // earlier than today
    }
    var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
    var randomDates = getRandomSet(y,m);
  
    for (i = 0; i &lt; randomDates.length; i++) {
      if($.inArray((m+1) + '-' + d + '-' + y,randomDates) != -1 || new Date() &gt; date) {
        return [true,"highlight","Some message"];
      }
    }
    return [true,"normal"]; // ordinary day
  }
  </code></pre>