Tweak the display time to use datetime.timedelta() instead of rolling my own with divmod() and friends

This commit is contained in:
David Thurstenson 2022-10-15 07:07:49 -05:00
parent fb617a5eec
commit 5637ec322a
1 changed files with 6 additions and 2 deletions

View File

@ -131,9 +131,13 @@ def countdown(
current_time -= update_interval
# Massage the current_time seconds count into human-readable minutes:seconds
display_time = divmod(abs(current_time), 60)
display_time = str(datetime.timedelta(seconds=abs(current_time)))[3:]
if current_time < 0:
display_time_sign = "-"
else:
display_time_sign = " "
print("current time: " + display_time_sign + str(display_time[0]) + ":" + str(display_time[1]))
print("current time: " + display_time_sign + display_time)