title: Continuously Check Time
body: <p>Firstly, how can I have jQuery continuously check the time, and add an <code>id</code> to a <code>&lt;div&gt;</code> tag if the current time is in between two set times? I'm making a clock for a school (where the clock is a website sent over cable to TVs in every room), where each period is expressed like this:</p>
  
  <pre><code>&lt;div class="period 1"&gt;Period 1: 7:32-8:14&lt;/div&gt;
  </code></pre>
  
  <p>I'm getting the start time and end time from <a href="http://datamapper.org" rel="nofollow">DataMapper</a>, so really, the code in the view (an eRB file) is:</p>
  
  <pre><code>&lt;% @periods.each do |@period| %&gt;
  &lt;div class="period &lt;%= @period.id %&gt;"&gt;&lt;%= @period.string %&gt;: &lt;%= @period.start_time.strftime("%I:%M") %&gt;&amp;ndash;&lt;%= @period.end_time.strftime("%I:%M") %&gt;&lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>My question is how I can get jQuery to continuously check the current time, and if it is in between <code>@period.start_time</code> and <code>@period.end_time</code>. If so, add <code>id="active"</code> to the <code>&lt;div&gt;</code>.</p>
  
  <p>Would I have to set up something for JavaScript to interface with Ruby via <code>.get</code>?</p>
  
  <p>If you have any questions, please ask.</p>