![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Help me please |
Hi I have recently tried to create a countdown timer to show the time remaining for the action to occur but my way seems to be lengthy and inefficient.
var time_total = 0
var time_dict = {"D" : 0, "H" : 0, "M" : 0, "S" : 0}
func start_time(given_time):
time_total = given_time * 3600 # into secs
convert_time()
func convert_time():
var time = time_total
while time >= 60: # get minutes
time -= 60
time_dict["M"] += 1
time_dict["S"] = time # rest is seconds
while time_dict["M"] >= 60:
time_dict["M"] -= 60
time_dict["H"] += 1
while time_dict["H"] >= 24:
time_dict["H"] -= 24
time_dict["D"] += 1
print(time_dict)
is there any better way