2,875
edits
(Add seconds to timespan conversion) |
m (Use hundreds of a second instead of seconds for timespan conversion in attempts of better accuracy) |
||
Line 201: | Line 201: | ||
end | end | ||
-- Creates a TimeSpan object from a total amount of seconds. | |||
function p.secondsToTimeSpan(totalSeconds) | function p.secondsToTimeSpan(totalSeconds) | ||
return p.actionTimeToTimeSpan(totalSeconds * 100) | |||
end | |||
local | --- Creates a TimeSpan object from action time (hundreds of a second). | ||
remainder = | -- @param str (number) The amount of action time to convert to a TimeSpan | ||
-- @return (TimeSpan) A TimeSpan object containing the seconds, minutes, hours and days the input amount of action time amounts to. | |||
function p.actionTimeToTimeSpan(totalActionTime) | |||
local days = math.floor(totalSeconds / 8640000) | |||
local remainder = totalSeconds % 8640000 | |||
local minutes = math.floor(remainder / | local hours = math.floor(remainder / 360000) | ||
local seconds = remainder | remainder = remainder % 360000 | ||
local minutes = math.floor(remainder / 6000) | |||
remainder = remainder % 6000 | |||
local seconds = math.floor(remainder / 100) | |||
return { | return { |
edits