Модуль:Serialization/TimeSpan: различия между версиями

м Pok переименовал страницу Модуль:Code/Формат/Время в Модуль:Serialization/TimeSpan
Нет описания правки
Строка 26: Строка 26:
end
end


-- Форматирование в "X час. Y мин. Z сек."
local function bold(n)
    return "<b>" .. tostring(n) .. "</b>"
end
 
-- Форматирование в "X час. Y мин. Z сек." с жирными числами
local function format_time(value)
local function format_time(value)
     local total_seconds = math.floor(value)
     local total_seconds = math.floor(value)
Строка 37: Строка 41:


     if hours > 0 then
     if hours > 0 then
         table.insert(parts, hours .. " час.")
         table.insert(parts, bold(hours) .. " час.")
     end
     end
     if minutes > 0 then
     if minutes > 0 then
         table.insert(parts, minutes .. " мин.")
         table.insert(parts, bold(minutes) .. " мин.")
     end
     end
     if seconds > 0 or #parts == 0 then
     if seconds > 0 or #parts == 0 then
         table.insert(parts, seconds .. " сек.")
         table.insert(parts, bold(seconds) .. " сек.")
     end
     end