I\'m trying to find the cleanest/most pythonic way of evaluating if \"now\" is between two times; However; the Start/End times may, or may not, fall across a day boundary- f
def is_hour_between(start, end, now):
is_between = False
is_between |= start <= now <= end
is_between |= end < start and (start <= now or now <= end)
return is_between
test with:
assert is_hour_between(6, 10, 6)
assert not is_hour_between(6, 10, 4)
assert is_hour_between(17, 20, 17)
assert not is_hour_between(17, 20, 16)