[bat] Fix bug introduced in 78e3d37fb5

Instead of setting the remaining time to reasonable values, remaining
time was always set to 0, because of math.min().
This commit is contained in:
J. Thalheim 2011-11-20 08:55:43 +01:00
parent e77576ac69
commit 5c7df93baa
1 changed files with 5 additions and 2 deletions

View File

@ -74,8 +74,11 @@ local function worker(format, warg)
return {state, percent, time}
end
-- Calculate time (but work around broken BAT/ACPI implementations)
local hoursleft = math.min(math.floor(timeleft), 0)
local minutesleft = math.min(math.floor((timeleft - hoursleft) * 60 ), 0)
local hoursleft, minutesleft = 0, 0
if timeleft > 0 then
hoursleft = math.floor(timeleft)
minutesleft = math.floor((timeleft - hoursleft) * 60 )
end
time = string.format("%02d:%02d", hoursleft, minutesleft)
end