title: Why does Safari/Opera not work with this javascript code?
body: <p>I am working on a calendar that will show bookings. The height of  containing the booking is calculated dynamically in proportion to the length of the booking.  The following code works perfectly well in Firefox but not in Safari or Opera:</p>
  
  <pre><code>function calculateBookingHeight(from, to) {
      var today = new Date;
      var end = new Date.UTC(today.getUTCFullYear(),today.getUTCMonth(),today.getUTCDate(),23);
      var start = new Date.UTC(today.getUTCFullYear(),today.getUTCMonth(),today.getUTCDate(),6);
      var from = new Date(from);
      var to = new Date(to);
      if (from &gt; start &amp;&amp; to &lt; end) {
          var difference = (to - from) / 120000;
      } else if (from &gt; start &amp;&amp; to &gt; end) {
          var difference = (end - from) / 120000;
      } else {
          var difference = 510
      }
      return difference;
  }
  </code></pre>
  
  <p>In summary, each hour on the calendar is a height of 30px. The second if statement deals with the end of the booking being the following day.</p>
  
  <p>If I replace the entire code block with <code>return 510</code>, Safari behaves as expected and sets the height of each booking to 510px so I assume it must be something in this function that is causing the problem.</p>
  
  <p>Any help would be appreciated.</p>
  
  <p>Thanks</p>
  
  <p>Robin</p>