I've to detect if two time periods are overlapping.
Every period has a start date and an end date.
I need to detect if my first time period (A) is overlapping with another one(B/C).
In my case, if the start of B is equal to the end of A, they are not overlapping(the inverse too)
I found the following cases:
So actually I'm doing this like this:
tStartA < tStartB && tStartB < tEndA //For case 1
tStartA < tEndB && tEndB <= tEndA //For case 2
tStartB < tStartA && tEndB > tEndA //For case 3
Simple check to see if two time periods overlap:
bool overlap = a.start < b.end && b.start < a.end;
or in your code:
bool overlap = tStartA < tEndB && tStartB < tEndA;
<= instead of
< if you change your mind about wanting to say that two periods that just touch each other overlap.)