I need some help with my code. I want to check if the variable start_time is less than, equal or greater than the current_time to compare for the time.
Here is the code:
start_date = str(stop_date[0])
stop_date = str(stop_date[1])
get_current_time = datetime.datetime.now().strftime('%H:%M')
get_start_time = time.strptime(start_date, '%Y%m%d%H%M%S')
start_time = time.strftime('%H:%M', get_start_time)
get_stop_time = time.strptime(stop_date, '%Y%m%d%H%M%S')
stop_time = time.strftime('%H:%M', get_stop_time)
current_time = str(get_current_time)
if start_time <> current_time <> stop_time:
print "program is half way"
Here is the output for the start_time:
19:00
19:00
19:00
19:00
19:00
19:00
19:00
Here is the output for the current_time:
00:10:36 T:5304 NOTICE: 00:09
Here is the output for the stop_time:
00:09:33 T:6824 NOTICE: 19:30
00:09:33 T:6824 NOTICE: 20:00
00:09:33 T:6824 NOTICE: 19:30
00:09:33 T:6824 NOTICE: 20:00
00:09:33 T:6824 NOTICE: 20:00
00:09:33 T:6824 NOTICE: 19:30
00:09:33 T:6824 NOTICE: 20:00
When I try this:
if start_time <=> current_time < stop_time:
print "program has finished"
It will give me an error: invalid syntax
It won't let me to have the = in the statement, I can only write on the statement with less than or greater than but not with the =.
How I can include the equal = with less than and greater than for the start_time to compare the time with current_time?
EDIT: Opps, sorry my mistake. I pasted the wrong code so here is what I am trying to do:
if start_time <=> current_time < stop_time:
print "program is half way"