Module:Duration
From Stationeers Community Wiki
More actions
Documentation for this module may be created at Module:Duration/doc
local duration = {}
function duration.fromSeconds(seconds)
local seconds = tonumber(seconds)
local result = ""
if seconds >= 3600 then
local hours = math.floor(seconds / 3600)
seconds = seconds - hours*3600
result = result .. hours .. " h"
end
if seconds >= 60 then
if #result > 0 then
result = result .. " "
end
local minutes = math.floor(seconds / 60)
seconds = seconds - minutes * 60
result = result .. minutes .. " min"
end
if seconds > 0 or #result == 0 then
if #result > 0 then
result = result .. " "
end
result = result .. seconds .. " s"
end
return result
end
return duration