Dec-13-2016, 06:46 PM
That seems to work just fine. Good idea!
Here is the code that now works before, after, and encompassing midnight.
Thank you
Here is the code that now works before, after, and encompassing midnight.
Thank you
tm= datetime.datetime.now() now_time = tm.time() # The next few lines are a test for a range that crosses midnight #now_time = datetime.time(23,54) # should fail #now_time = datetime.time(23,55) # should passs #now_time = datetime.time(0,4) # should fail #now_time = datetime.time(0,3) # should pass starthr = 23 # befot=re midnight startmin = 55 stophr = 0 # after midnight stopmin = 3 if stophr >= starthr: if now_time >= datetime.time(starthr, startmin) and now_time <= datetime.time(stophr,stopmin): print("in the range") else: if now_time <= datetime.time(stophr,stopmin) or now_time >= datetime.time(starthr, startmin): print("in the range") else: print("not in the range")