Module:Time: Difference between revisions

Remove unused functions
No edit summary
(Remove unused functions)
Line 2: Line 2:


local Number = require('Module:Number')
local Number = require('Module:Number')
local StringBuilder = require('Module:StringBuilder')


-- 123 => 00:02:03
function p._secondsToHMS(totalSeconds)
function p.secondsToHMS(totalSeconds)
local days = math.floor(totalSeconds / (24 * 60 * 60))
local days = math.floor(totalSeconds / (24 * 60 * 60))
if days >= 1 then
if days >= 1 then
Line 13: Line 13:
end
end


-- 123 => 2 minutes, 3 seconds
function p._secondsToHuman(totalSeconds)
function p.secondsToHuman(totalSeconds)
ts = Number.secondsToTimeSpan(totalSeconds)
ts = Number.secondsToTimeSpan(totalSeconds)
if ts.totalSeconds < 60 then
if ts.totalSeconds < 60 then
Line 39: Line 38:
end
end


function p.testSecondsToHuman(s)
function p.secondsToHuman(frame)
output = {}
local frame = frame or mw.getCurrentFrame()
for i, s in ipairs(
local args = frame:getParent().args
{-1, 0, 0.5, 5 * 60, 5 * 60 + 20,
return p._secondsToHuman(args[0])
6 * 60 * 60, 6 * 60 * 60 + 20, 6 * 60 * 60 + 3 * 60 + 20,
1 * 24 * 60 * 60, 2 * 24 * 60 * 60 + 3 * 60 * 60 + 2 * 60 + 1}) do
table.insert(output, string.format('%s = %s', s, p.secondsToHuman(s)))
end
return table.concat(output, ' || ')
end
 
function p.prettyPrintTime(frame)
if frame == nil then
return '<invalid frame object>'
end
if frame.args[1] == nil then
return '<missing argument seconds>'
end
local seconds = tonumber(frame.args[1])
if frame.args["hms"] == "true" then
return p.secondsToHMS(seconds)
else
return p.secondsToHuman(seconds)
end
end
end


return p
return p
2,875

edits