When you do:
if time("%d","%d") <= now.time() <= time("%d","%d") % (start_time_hour, start_time_minute, end_time_hour, end_time_minute)
the %
operator its not doing what you think it should do.
Its not the same:
time("%d" % 5, "%d" % 4)
than
time("%d", "%d") % (5, 4)
the last line will complains with the error: an integer is required
.
Also you can:
hours = 5
min = 4
time(hours, min)
So you can change the line to:
if time(start_time_hour, start_time_minute) <= now.time() <= time(end_time_hour, end_time_minute)