title: jQuery UI Datepicker conditional mess.. is there a cleaner way to do this?
body: <p>I'm setting up something of an "appointment" scheduler using the <a href="http://docs.jquery.com/UI/Datepicker" rel="nofollow">jQuery UI Datepicker</a>, but I have a few conditions that I needed to implement:</p>
  
  <ul>
  <li>Customer could not schedule on a Sunday</li>
  <li>Customer can't schedule after 12pm on Saturday (have not implemented this)</li>
  <li>Can't schedule <em>next day</em> if the current time is past 12pm </li>
  <li>Can't schedule massively in advance (I chose +2 months)</li>
  <li>Can't schedule for the current day (and obviously not the past)</li>
  </ul>
  
  <p>Here is my current code:</p>
  
  <pre><code>$(document).ready(function() {
      function noSundays(date) {
          return [date.getDay() != 0, ''];
      }
      var timezone = "EST";
      $.getJSON("http://json-time.appspot.com/time.json?tz="+timezone+"&amp;callback=?",
      function(data){
          if (data.hour &lt; 12) {
              $("#datepicker").datepicker({ 
              beforeShowDay: noSundays,
              minDate: '+1d',
              maxDate: '+2m' });
          } else {
              $("#datepicker").datepicker({ 
              beforeShowDay: noSundays,
              minDate: '+2d',
              maxDate: '+2m' });
          }
      })
  });
  </code></pre>
  
  <p>So we set noSundays, get the current time in EST from the JSON server and if it's before 12PM we fire up .datepicker with minDate : +1d (tomorrow), if it's after 12PM we use minDate : +2d. This code <em>works</em> but I feel like I'm doing something really wrong.  I'm still relatively inexperienced and would love to know if there is a better way to write this.</p>
  
  <p>Thank you.</p>