Answers for "period compare array of date overlap"

0

period compare array of date overlap

checkDateTimeOverlap = (dateTimes)=>{
        let isOverlap = false;
        dateTimes.forEach((time,i) => {
            let  st1 = time[0];
            let  et1 = time[1];
          
            dateTimes.forEach((time2,j) => {               
                if(i != j){
                    let st2 = time2[0];
                    let et2 = time2[1];
                    if (st1 >= st2 && st1 <= et2 || et1 >= st2 && et1 <= et2 || st2 >= st1 && st2 <= et1 || et2 >= st1 && et2 <= et1) {
                        isOverlap =  true;
                    }else{
                        isOverlap =  false;
                    }
                }
            })
        }); 

        return isOverlap;
    }
Posted by: Guest on May-10-2021

Browse Popular Code Answers by Language