Модуль:Code/Формат/Время
Материал из Space Station 14 Вики
Для документации этого модуля может быть создана страница Модуль:Code/Формат/Время/doc
local p = {}
local function format_time(mode, value)
local total_seconds = mode == "minutes" and (value * 60) or value
local hours = math.floor(total_seconds / 3600)
local minutes = math.floor((total_seconds % 3600) / 60)
local seconds = total_seconds % 60
local parts = {}
if hours > 0 then
table.insert(parts, hours .. " час.")
end
if minutes > 0 then
table.insert(parts, minutes .. " мин.")
end
if seconds > 0 or #parts == 0 then
table.insert(parts, seconds .. " сек.")
end
return table.concat(parts, " ")
end
function p.main(frame)
local args = frame.args
local mode = args[1] or "seconds"
local value = tonumber(args[2]) or 0
return format_time(mode, value)
end
return p