SecondsToDays

Two functions for formatting seconds (as returned by TIME_PLAYED_MSG or by GetQuestResetTime) to a human-readable format.

formatSeconds
Converts seconds to "s", "m:ss", "h:mm:ss", or "d:hh:mm:ss" format

local function formatSeconds(seconds) local d, h, m, s;     -- Allowing fractional values, since string:format("%d") will coerce to integer d = seconds / 86400;                -- 86400 seconds in a day h = (seconds % 86400) / 3600;       -- seconds in the left-over day, divided by seconds in an hour m = (seconds % 86400 % 3600) / 60;  -- seconds in the left-over hour, divided by seconds in a minute s = seconds % 86400  % 3600  % 60;  -- seconds in the left-over minute -- Add or remove output formats you want if d >= 1 then return ("%d:%02d:%02d:%02d"):format(d,h,m,s); end; if h >= 1 then return (    "%d:%02d:%02d"):format(  h,m,s); end; -- For better clarity, you could keep the minutes even if they're zero: --            return (          "%d:%02d"):format(    m,s); if m >= 1 then return (         "%d:%02d"):format(    m,s); end; return s; end

Examples
Example usage: /run print("Dailies rollover in "..formatSeconds(GetQuestResetTime))

Example runs: /run print(formatSeconds(100)) 1:40 /run print(formatSeconds(100000)) 1:03:46:40 /run print(formatSeconds(3606)) 1:00:06

Fractions are ignored: /run print(formatSeconds(3606.4)) 1:00:06

Negative numbers wind up being interpreted oddly, but understandably: /run print(formatSeconds(-3)) 23:59:57 /run print(formatSeconds(-3606)) 22:59:54

secondsToDays
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)

Arguments

 * inputSeconds : Number - the amount of seconds to convert

Returns

 * result : String - the equivalent combination, using the format: "# days/# hours/# minutes/# seconds"

Details

 * Works with any amount of seconds

Code
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