WoW:USERAPI SecondsToDays

From AddOn Studio
Revision as of 04:49, 15 August 2023 by Move page script (talk | contribs) (Move page script moved page USERAPI SecondsToDays to USERAPI SecondsToDays without leaving a redirect)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
This page documents a <i>user-defined function</i> that you can copy and paste into your addon. Replace PREFIX with your addon or lib prefix to avoid conflicts between different versions of these functions.

User defined functions

Fast function for converting the TIME_PLAYED_MSG response (or any source of seconds) to a X days/X hours/X minutes/X seconds format.

secondsToDays(inputSeconds)


Function Parameters[edit]

Inputs[edit]

inputSeconds
inputSeconds
Number

Returns[edit]

"X days/X hours/X minutes/X seconds"
X days/X hours/X minutes/X seconds
String


Details[edit]

Works with any amount of seconds

Code[edit]

function secondsToDays(inputSeconds)
 fdays = math.floor(inputSeconds/86400)
 fhours = math.floor((bit.mod(inputSeconds,86400))/3600)
 fminutes = math.floor(bit.mod((bit.mod(inputSeconds,86400)),3600)/60)
 fseconds = math.floor(bit.mod(bit.mod((bit.mod(inputSeconds,86400)),3600),60))
 return fdays.." days/"..fhours.." hours/"..fminutes.." minutes/"..fseconds.." seconds"
end