Closed usman5251 closed 1 year ago
@usman5251
For a time being, you could check such cases by using get_timedelta_second
method. for example:
if not time_range.is_intersection(x):
return False
if time_range.intersection(x).get_timedelta_second() == 0:
# get_timedelta_second will return 0 if start/end time for x == start/end time for time_range,
return False
return True
Probably, adding an argument to is_intersection
method that makes it possible to exclude start/end time would be preferable in the future
Oh that's super nice and clean!! Thanks alot @thombashi.
Since DateTimeRange 2.0.0
, you can write as follows:
time_range.is_intersection(x, intersection_threshold=datetime.timedelta(seconds=1)):
Sorry the title is a bit unclear but I'll try to describe what I want to do as clear as possible. So like in this example code, this returns True:
But if x has same start (or) end minute same as time_range I want it to return False, Currently it returns true.
So, if start/end time for x == start/end time for time_range, I want it to return False on is_intersection(), is there a simple way to achieve this?