Skip to content Skip to sidebar Skip to footer

Time Interval Overlap In Python

Suppose I have list of time interval like a = [datetime.time(0,0),datetime.time(8,0)] Now I Have lacs of intervals in list like given below. b = [[datetime.time(0,0),datetime.time

Solution 1:

Your code has errors (usage of datetime/datetime.time).

This code will filter out from b everything, that does not overlap with a:

b = [x for x in b if a[0] < x[1] and x[0] < a[1]]

Post a Comment for "Time Interval Overlap In Python"