mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
fix util.secondsToHClock when hmsFormat is true (#5640)
This commit is contained in:
@@ -156,7 +156,11 @@ function util.secondsToHClock(seconds, withoutSeconds, hmsFormat)
|
||||
if withoutSeconds then
|
||||
if hours == "0" then
|
||||
mins = string.format("%.f", round(seconds / 60))
|
||||
return mins .. "'"
|
||||
if hmsFormat then
|
||||
return T(_("%1m"), mins)
|
||||
else
|
||||
return mins .. "'"
|
||||
end
|
||||
end
|
||||
-- @translators This is the 'h' for hour, like in 1h30. This is a duration.
|
||||
return T(_("%1h%2"), hours, mins)
|
||||
|
||||
@@ -430,6 +430,22 @@ describe("util module", function()
|
||||
assert.is_equal("10h01",
|
||||
util.secondsToHClock(36060, true))
|
||||
end)
|
||||
it("should round seconds to minutes in 0h00m format", function()
|
||||
assert.is_equal("1m",
|
||||
util.secondsToHClock(89, true, true))
|
||||
assert.is_equal("2m",
|
||||
util.secondsToHClock(90, true, true))
|
||||
assert.is_equal("2m",
|
||||
util.secondsToHClock(110, true, true))
|
||||
assert.is_equal("1h00",
|
||||
util.secondsToHClock(3600, true, true))
|
||||
assert.is_equal("1h00",
|
||||
util.secondsToHClock(3599, true, true))
|
||||
assert.is_equal("59m",
|
||||
util.secondsToHClock(3569, true, true))
|
||||
assert.is_equal("10h01",
|
||||
util.secondsToHClock(36060, true, true))
|
||||
end)
|
||||
it("should convert seconds to 0h00'00'' format", function()
|
||||
assert.is_equal("0''",
|
||||
util.secondsToHClock(0))
|
||||
|
||||
Reference in New Issue
Block a user