mirror of
https://github.com/bolucat/Archive.git
synced 2026-04-23 00:17:16 +08:00
Update On Fri Jul 11 20:40:25 CEST 2025
This commit is contained in:
@@ -1285,3 +1285,32 @@ function luci_types(id, m, s, type_name, option_prefix)
|
||||
end
|
||||
end
|
||||
end
|
||||
function format_go_time(input)
|
||||
input = input and trim(input)
|
||||
local N = 0
|
||||
if input and input:match("^%d+$") then
|
||||
N = tonumber(input)
|
||||
elseif input and input ~= "" then
|
||||
for value, unit in input:gmatch("(%d+)%s*([hms])") do
|
||||
value = tonumber(value)
|
||||
if unit == "h" then
|
||||
N = N + value * 3600
|
||||
elseif unit == "m" then
|
||||
N = N + value * 60
|
||||
elseif unit == "s" then
|
||||
N = N + value
|
||||
end
|
||||
end
|
||||
end
|
||||
if N <= 0 then
|
||||
return "0s"
|
||||
end
|
||||
local result = ""
|
||||
local h = math.floor(N / 3600)
|
||||
local m = math.floor(N % 3600 / 60)
|
||||
local s = N % 60
|
||||
if h > 0 then result = result .. h .. "h" end
|
||||
if m > 0 then result = result .. m .. "m" end
|
||||
if s > 0 or result == "" then result = result .. s .. "s" end
|
||||
return result
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user