mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
#1723 Add time to read into the status bar
Add new statuses: TB - book time to read TC - chapter time to read Fix backward compatible in statistics plugin
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
local util = {}
|
||||
|
||||
function util.stripePunctuations(word)
|
||||
@@ -47,4 +46,30 @@ function util.gsplit(str, pattern, capture)
|
||||
end)
|
||||
end
|
||||
|
||||
--https://gist.github.com/jesseadams/791673
|
||||
function util.secondsToClock(seconds, withoutSeconds)
|
||||
local seconds = tonumber(seconds)
|
||||
if seconds == 0 or seconds ~= seconds then
|
||||
if withoutSeconds then
|
||||
return "00:00";
|
||||
else
|
||||
return "00:00:00";
|
||||
end
|
||||
else
|
||||
local hours = string.format("%02.f", math.floor(seconds / 3600));
|
||||
local mins = string.format("%02.f", math.floor(seconds / 60 - (hours * 60)));
|
||||
if withoutSeconds then
|
||||
return hours .. ":" .. mins
|
||||
end
|
||||
local secs = string.format("%02.f", math.floor(seconds - hours * 3600 - mins * 60));
|
||||
return hours .. ":" .. mins .. ":" .. secs
|
||||
end
|
||||
end
|
||||
|
||||
function util.tablelength(T)
|
||||
local count = 0
|
||||
for _ in pairs(T) do count = count + 1 end
|
||||
return count
|
||||
end
|
||||
|
||||
return util
|
||||
|
||||
Reference in New Issue
Block a user