title: Validating date between opening hours in JS
body: <p>I was wondering what the best approach would be to validate a date is within the correct opening hours of a shop...</p>
  
  <p>I am creating a website for a golf professional and am taking bookings for lessons on it. I have used fullCalendar for the calendar and integrated it with google calendar so it can be easily sync'd to the pro's mobile easily etc.</p>
  
  <p>As part of the calendar, when a customer clicks on a time slot I am provided with a date object by fullcalendar. I want to validate that this selected slot falls within the opening times of the shop for lessons to be taken etc.</p>
  
  <p>The times will be retrieved from a db table at some point but I can have them returned in JSON onto the page if it works best - but thats not the purpose of this question...</p>
  
  <p>The opening hours differ depending on the day of the week as well as the "season" [summer times -vs- winter times]</p>
  
  <pre><code>ie:
   Summer Times
      Monday = 10:00 - 21:00
      Tuesday = 10:00 - 21:00
      Wednesday = 10:00 - 21:00
      Thursday = 10:00 - 21:00
      Friday = 10:00 - 21:00
      Saturday = 08:00 - 18:00
      Sunday = 08:00 - 18:00
  
   Winter Times
      Monday = CLOSED
      Tuesday = 10:00 - 18:30
      Wednesday = 10:00 - 18:30
      Thursday = 12.00 – 20.30
      Friday = 12.00 – 20.30
      Saturday = 08:00 - 18:00
      Sunday = 08:00 - 18:00
  </code></pre>
  
  <p>What would the "best" way be to validate this?</p>
  
  <p>would the best option be to simply do nested if/switch statements..</p>
  
  <pre><code>[sudo code]
  if(summer}
  {
      switch(date.getDay())
      {
      case 1:
            if(time &gt; mondayOpeningTime &amp;&amp; time &lt; mondayCloseTime)
            {
              return true;
            }
            else
            {
              return false;
            }
        break;
      case 2:
        execute code block 2
        break;
      .....
      default:
        code to be executed if n is different from case 1 and 2
      }
  }
  else
  {
      // Same as summer logic but for winter times etc..
  } 
  </code></pre>
  
  <p>Or is there a better way of doing this?</p>
  
  <p>Apologies for the long post/question but thanks in advance to anyone who spends the time reading and responding to it :)</p>
  
  <p>Chris</p>