I'm trying to see if a datetime is within a range of another datetime.
Essentially, I have two lists. One containing times of potential events, and one containing times when people are unavailable. I want to cross reference them to check that the event(s) will not run when people are unavailable.
I have this function at the minute, but having some trouble actually the configuration of the if statements working, as I'm getting them wrong and having dates wrongly removed.
def check_times(event_times, unavailable_times):
for event_time in event_times:
for unavailable_time in unavailable_times:
if (event_time[0] >= unavailable_time[1]) and (event_time[1] >= unavailable_time[2])
event_times.remove(event_time)
break
With regard to below, unavailable_times[1] refers to the beginning of the time where the person is unavailable and unavailable_times[2] is when that time ends. event_times[0] is the beginning of the event and event_times[1] is the end time of the event.
Essentially, say I want a meeting to run from 13:30 - 15:00, but person X is busy from 14:15 - 14:40. I then would want to disregard the 13:30 - 15:00 period. I'm just having a bit of a hard time configuring the if statements to reflect this.