title: Calculate weekdays and weekends count between two dates without considering daylight saving - javascript
body: <p>Due to daylight saving time in London, I'm not able to get the correct count for weekdays and weekend days. In the below fiddle 26/10/2019 is considering at times as weekday and at times as a weekend.
  I want to get the output for the below fiddle is 
  "workingDays": 1,
    "weekendDays": 2</p>
  
  <p>Any suggestions, please?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var startDate = new Date('2019-10-26');
  var endDate = new Date('2019-10-28');
  var workingDays = number_of_working_days(startDate, endDate);
  var weekendDays = number_of_weekend_days(startDate, endDate);
  console.log({
    'workingDays': workingDays,
    'weekendDays': weekendDays
  })
  
  function number_of_working_days(startDate, endDate) {
    var workingDays = 0;
    for (var i = startDate; i &lt;= endDate; i = i + (60 * 60 * 24)) {
      if (i.getDay() &lt;= 5) {
        workingDays = workingDays + 1;
      }
  
    }
    return workingDays;
  }
  
  function number_of_weekend_days(startDate, endDate) {
    var weekendDays = 0;
    for (var i = startDate; i &lt;= endDate; i = i + (60 * 60 * 24)) {
      if (i.getDay() &gt; 5) {
        weekendDays = weekendDays + 1;
      }
    }
    return weekendDays;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>