JSFiddle - React, Tailwind, and code Playground
JavaScript
var date1 = new Date(Date.parse('Apr 10, 2014'));
var date2 = new Date(Date.parse('Apr 14, 2014'));
function containsWeekend(d1, d2)
{
// note: I'm assuming d2 is later than d1 and that both d1 and d2 are actually dates
// you might want to add code to check those conditions
var interval = (d2 - d1) / (1000 * 60 * 60 * 24); // convert to days
if (interval > 5) {
return true; // must contain a weekend day
}
var day1 = d1.getDay();
var day2 = d2.getDay();
return !(day1 > 0 && day2 < 6 && day2 > day1);
}
console.log(containsWeekend(date1,date2));