'find time slot in range of datetime
guys i am struggling to implement this, i have a start date, end date and a list of tuples of datetime ranges, and then i have a an event for like 30 minutes, i want to check where that event could be placed between the above time range
start = datetime(2022, 5, 19, 7, 0)
end = start + timedelta(hours=3.5)
x = c.get_event_detail(start, end)
print(start)
print(x)
print(end)
output:
2022-05-19 07:00:00
[(datetime.datetime(2022, 5, 19, 9, 30), datetime.datetime(2022, 5, 19, 11, 0)), (datetime.datetime(2022, 5, 19, 9, 0), datetime.datetime(2022, 5, 19, 10, 0)), (datetime.datetime(2022, 5, 19, 7, 0), datetime.datetime(2022, 5, 19, 9, 0)), (datetime.datetime(2022, 5, 19, 7, 30), datetime.datetime(2022, 5, 19, 8, 15))]
2022-05-19 10:30:00
well i tried to add start and end and convert them into list then sort then iterate over them but the issue is that the some ending part of the tuple has ovverride dateranges, for example (6:00 pm to 8 pm and 7 pm to 8 pm) the event is just an event with title and a duration and i want to check where it can be placed in the given range, its a part of my program, so i picked the relavant code only.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
