//判断两个时间段是否有交集
isDateIntersection(start1, end1, start2, end2) {
var startdate1 = new Date(start1.replace("-", "/").replace("-", "/"));
var enddate1 = new Date(end1.replace("-", "/").replace("-", "/"));
var startdate2 = new Date(start2.replace("-", "/").replace("-", "/"));
var enddate2 = new Date(end2.replace("-", "/").replace("-", "/"));
if (startdate1 > startdate2 && startdate1 < enddate2) {
return true;
}
if (enddate1 > startdate2 && enddate1 < enddate2) {
return true;
}
if (startdate1 < startdate2 && enddate1 > enddate2) {
return true;
}
return false;
}
如果还有需求是这组的两个时间点和另一组时间点不相等
//根据传入的num值判断是开始时间还是结束时间
isDuringDate(beginDateStr, endDateStr, curDateStr,num) {
var curDate = new Date(curDateStr),
beginDate = new Date(beginDateStr),
endDate = new Date(endDateStr);
if(num == 0){
if (curDate >= beginDate && curDate <= endDate) {
return true;
}
}else{
if (curDate >= beginDate && curDate <= endDate) {
return true;
}
}
return false;
},