I am trying to compare two datetime.time
but I keep getting the error:
"An exception of type TypeError occurred. Arguments: ("'<=' not supported between instances of 'datetime.datetime' and 'datetime.time'",)"
I've checked all of the types and they all seem to be of type datetime.time
after I make a conversion (see print statements), but the terminal still screams the same error
print(appointment_start, type(appointment_start)) # 04:56:00 type <class 'datetime.time'>
print(appointment_end, type(appointment_end)) # <class 'datetime.time'>
print(time, type(time)) # <class 'datetime.datetime'>
formatted_time = time.time() # trying to convert to datetime.time
print(formatted_time, type(formatted_time)) # 09:00:00 <class 'datetime.time'>
if formatted_time >= appointment_start and time <= appointment_end:
print('unavailable')
return True
I've read SO answers that point out nothing is wrong with using >=
. I even tried just using >
but still the same problem arises.