Module:Calculator/ETA: Difference between revisions

m
Use timespan from Module:Numbers
m (Allow currentExp to be entered with a suffix)
m (Use timespan from Module:Numbers)
Line 4: Line 4:
local number = require('Module:Number')
local number = require('Module:Number')


local function formatTime(timeInHundredths)
function p.formatTime(timeInHundredths)
    local sec = math.floor(timeInHundredths / 100)
local timespan = number.secondsToTimeSpan(timeInHundredths / 100)
    local min = math.floor(timeInHundredths / 60000)
    local hrs = math.floor(timeInHundredths / 360000)
    local days = math.floor(timeInHundredths / (360000 * 24))


if days == 0 then
if timespan.days == 0 then
return string.format("%02dh %02dm %02ds", hrs % 24, min % 60, sec % 60)
return string.format("%02dh %02dm %02ds", timespan.hours, timespan.minutes, timespan.seconds)
else
else
return string.format("%d days %02dh %02dm %02ds", days, hrs % 24, min % 60, sec % 60)
return string.format("%d days %02dh %02dm %02ds", timespan.days, timespan.hours, timespan.minutes, timespan.seconds)
end
end
end
end
1,019

edits