This question: Get difference between 2 dates in javascript? proposed the following way to calculate the difference between two dates:
var _MS_PER_DAY = 1000 * 60 * 60 * 24;
// a and b are javascript Date objects
function dateDiffInDays(a, b) {
  // Discard the time and time-zone information.
  var utc1 = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());
  var utc2 = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate());
  return Math.floor((utc2 - utc1) / _MS_PER_DAY);
}
That's correct for some purposes, but not all purposes. Specifically, with day light savings time you could have a 24-hour span that does not pass midnight, which does not count as a full day for medical billing purposes, for example. How do I calculate specifically the number of midnights that occur between two dates in javascript?
 
    