Module:Number: Difference between revisions

m
Fix parameter naming
(Add seconds to timespan conversion)
m (Fix parameter naming)
(2 intermediate revisions by the same user not shown)
Line 201: Line 201:
end
end


--- Creates a TimeSpan object from seconds.
-- Creates a TimeSpan object from a total amount of seconds.
-- @param str (number) The amount of seconds to convert to a TimeSpan
-- @return (TimeSpan) A TimeSpan object containing the seconds, minutes, hours and days the input amount of seconds amounts to.
function p.secondsToTimeSpan(totalSeconds)
function p.secondsToTimeSpan(totalSeconds)
    local days = math.floor(totalSeconds / 86400)
return p.actionTimeToTimeSpan(totalSeconds * 100)
    local remainder = totalSeconds % 86400
end


     local hours = math.floor(remainder / 3600)
--- Creates a TimeSpan object from action time (hundreds of a second).
     remainder = remainder % 3600
-- @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(totalActionTime / 8640000)
     local remainder = totalActionTime % 8640000


     local minutes = math.floor(remainder / 60)
    local hours = math.floor(remainder / 360000)
     local seconds = remainder % 60
    remainder = remainder % 360000
 
     local minutes = math.floor(remainder / 6000)
    remainder = remainder % 6000
   
     local seconds = math.floor(remainder / 100)


     return {
     return {
Line 220: Line 227:
         seconds = seconds,
         seconds = seconds,
          
          
         totalDays = totalSeconds / 86400,
         totalDays = totalActionTime / 8640000,
         totalHours = totalSeconds / 3600,
         totalHours = totalActionTime / 360000,
         totalMinutes = totalSeconds / 60,
         totalMinutes = totalActionTime / 6000,
         totalSeconds = totalSeconds
         totalSeconds = totalActionTime / 100
     }
     }
end
end


return p
return p
915

edits