02.01.2023, 08:47
Here's a different formatting function that will only show the largest units for the time (days, hours, minutes, seconds):
If you have a fixed total run time then you can use this:
Code:
function formattimealt(output, seconds)
local minutes = math.floor(seconds / 60)
local hours = math.floor(minutes / 60)
local days = math.floor(hours / 24)
local res
seconds = seconds % 60
minutes = minutes % 60
hours = hours % 24
if days > 0 then
res = days .. 'd'
elseif hours > 0 then
res = hours .. 'h'
elseif minutes > 0 then
res = minutes .. 'm'
else
res = seconds .. 's'
end
grp.update(output, res)
end
If you have a fixed total run time then you can use this:
Code:
time_total = 22 * 3600 -- 22 hours in seconds
time_remaining = math.max(0, time_total - time_curr)
formattimealt(out_total, time_remaining)