Your problem is not isolating pure time from
datetime
. Your problem is treating time as string. You cannot compare objects of incompatible types. Comparison time with a string, even it is supposed to represent time, in your opinion, means no more that comparing time with the phrase "I am a little blue balloon in the shy".
You should never try it, even if you can "convert"
datetime
to string. Correct general approach is calculation of
datetime.timedelta
for two moments of time. Not only it will give you the check for the identical points in time, but you can also check which moment of time is sooner.
Note that if you want to abstract out the date and compare only the time, you can use
datetime.time()
.
Everything is explained here:
https://docs.python.org/2/library/datetime.html[
^].
Please try to learn the concepts of typing and basic ideas of programming. Try to work with data, not strings representing data.
—SA