Created
April 4, 2020 14:50
-
-
Save pavelpy/f139d388aa4d5941573f306723805aab to your computer and use it in GitHub Desktop.
Check intersection of datetime ranges.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_dates_intersect(dt1_from, dt1_to, dt2_from, dt2_to): | |
"""Returns True if there is an intersection of datetime ranges.""" | |
first_condition = (dt1_from <= dt2_from <= dt1_to) | |
second_condition = (dt2_from <= dt1_from <= dt2_to) | |
return first_condition or second_condition |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment