-
Notifications
You must be signed in to change notification settings - Fork 0
/
overlap
31 lines (31 loc) · 886 Bytes
/
overlap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function doesOverLap(startHour1, startHour2, startMin1, startMin2, duration1, duration2, days1, days2) {
var overlapCount = 0;
if (days1 === "None" || days2 === "None") {return false;}
for(var i = 0; i < days2.length; i++){
if(days1.indexOf(days2[i]) !== -1){overlapCount++;}
}
if(overlapCount === 0){
return false;
}
if (startHour1 === startHour2 && startMin1 === startMin2) {
return true;
}
if (startHour1 < 8) {
startHour1 += 12;
}
if (startHour2 < 8) {
startHour2 += 12;
}
startHour1 += startMin1 / 60
startHour2 += startMin2 / 60
if (startHour1 < startHour2) {
if (startHour1 + duration1 / 60 > startHour2) {
return true;
}
} else {
if (startHour2 + duration2 / 60 > startHour1) {
return true;
}
}
return false;
}