Rudimentary fix for bug introduced on bat time remaining

This commit is contained in:
Wtfcoder 2011-11-19 22:45:15 +07:00
parent 78e3d37fb5
commit 9eca19a838
1 changed files with 10 additions and 3 deletions

View File

@ -71,10 +71,17 @@ local function worker(format, warg)
elseif state == "-" then
timeleft = tonumber(remaining) / tonumber(rate)
else
return {state, percent, time}
return {state, percent, time}
end
local hoursleft
local minutesleft
if timeleft < 0 then
hoursleft = 0
minutesleft = 0
else
hoursleft = math.floor(timeleft)
minutesleft = math.floor((timeleft - hoursleft) * 60 )
end
local hoursleft = math.min(math.floor(timeleft), 0)
local minutesleft = math.min(math.floor((timeleft - hoursleft) * 60 ), 0)
time = string.format("%02d:%02d", hoursleft, minutesleft)
end