local module = {}
function module:get(timeInSeconds)
local years = math.floor(timeInSeconds / 31556926)
timeInSeconds = timeInSeconds % 31556926
local months = math.floor(timeInSeconds / 2629744)
timeInSeconds = timeInSeconds % 2629744
local days = math.floor(timeInSeconds / 86400)
timeInSeconds = timeInSeconds % 86400
local hours = math.floor(timeInSeconds / 3600)
timeInSeconds = timeInSeconds % 3600
local minutes = math.floor(timeInSeconds / 60)
local seconds = timeInSeconds % 60
local parts = {}
if years > 0 then table.insert(parts, years .. "y") end
if months > 0 then table.insert(parts, months .. "m") end
if days > 0 then table.insert(parts, days .. "d") end
if hours > 0 then table.insert(parts, hours .. "h") end
if minutes > 0 then table.insert(parts, minutes .. "m") end
if #parts == 0 then
return seconds .. "s"
end
return table.concat(parts, " ")
end
return module
Last updated:09/06/25