title: Determining if day or night after calculating sunset and sunrise times
body: <p>I've successfully calculated the sunrise and sunset times based on user location and I store the hours and minutes in an array. So the hours is the zeroth element and the minutes are the first, looking like this <code>var sunrise = [09, 23];</code> and <code>var sunset = [20, 49];</code></p>
  
  <p>What I want to do is do something when it is dawn, then something separate when day, then something separate when dusk, and something separate when night. let's just say, for now, I want to alert what segment of the day it is.</p>
  
  <p>I define dawn as 1 hour before sunrise to 1 hour after sunrise. Day as inbetween dawn and dusk. Dusk as 1 hour before sunset until 1 hour after sunset. And night as between dusk and dawn or more simply anything else.</p>
  
  <p>I've tried doing this with if statements as below, but even when the sunrise and sunset are correct, it says it is dusk in the night time.</p>
  
  <pre><code>if(hours&gt;(sunset[0]-1) &amp;&amp; (hours&lt;=sunset[0]+1 &amp;&amp; minutes&lt;=sunset[1])){
      alert("dusk");
  }
  else if(hours&gt;(sunrise[0]-1) &amp;&amp; (hours&lt;=sunrise[0]+1 &amp;&amp; minutes&lt;=sunrise[1])){
      alert("dawn");
  }
  else if((hours&gt;sunrise[0]+1 || (hours===sunrise[0]+1 &amp;&amp; minutes&gt;sunrise[1])) &amp;&amp; (hours&lt;sunset[0]-1) || (hours===sunset[0]-1 &amp;&amp; minutes&lt;sunset[1])){
      alert("day");
  }
  else if(hours&gt;sunset[0]+1 || (hours === sunset[0]+1 &amp;&amp; minutes&gt;sunset[1]) &amp;&amp; (hours&lt;sunrise[1]-1 || (hours===sunrise[1]-1 &amp;&amp; minutres&lt;sunrise[1]))){
      alert("night");
  }
  else{
      alert("night"); 
  }
  </code></pre>