I am trying to find the reverse intersection to see if two teams can play each other but having a hard time figuring out the precise code to do it.
The class represtenting the ranges below would contain two properties, a start time and end time which can be date time or timespan. Each team can have a list of these. The timespan property goes down to the minute so 2:21 pm is valid.
Team 1 can't play between those two times listed, so they can only play from 10:00 AM-5:00 PM. We store the exclusion though.
Team 2 can play 8:00 AN -12:00 PM.
Meaning Team 1 and Team 2 can play between 10-12. Is there a good way to calculate this out in code?
Team 1
List<Restriction>
Restriction
StartTime: 8:00 AM
EndTime: 10:00 AM
Restriction
StartTime: 5:00 PM
EndTime: 9:00 PM
Team 2
List<Restriction>
Restriction
StartTime: 12:00 PM
EndTime: 9:00 PM