Answer the question
In order to leave comments, you need to log in
How to understand if one time period overlaps another?
Hi Habr!
The question is the following
. I have two time intervals: 09:20 - 10:20 and 10:21 - 11:21
How to make it so that when entering the next time interval, it checks if it captures these intervals.
That is, what would sweep away options like 08:00 - 12:00, 09:25 - 16:00, etc.
I can’t solve the problem, please help)
Answer the question
In order to leave comments, you need to log in
It all depends on the library you are using. For example datetime like this:
from datetime import datetime
a = datetime(year=2020, month=1, day=1, hour=9, minute=0, second=0)
b = datetime(year=2020, month=1, day=1, hour=12, minute=0, second=0)
c = datetime(year=2020, month=1, day=1, hour=18, minute=0, second=0)
if a < c < b:
print('In range')
else:
print('Out of range')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question