diff options
| author | Philipp Gesang <phg42.2a@gmail.com> | 2013-06-09 11:34:33 +0200 | 
|---|---|---|
| committer | Philipp Gesang <phg42.2a@gmail.com> | 2013-06-09 11:34:33 +0200 | 
| commit | 40cf2319dbf8b2d6796c7941a31795cd2cb55eb3 (patch) | |
| tree | 3ccabaa43445a099852e45add9fa93574fab59bb /lualibs-util-prs.lua | |
| parent | c0eecc6f6ac9622b498134d8415010b077f4d57d (diff) | |
| download | lualibs-40cf2319dbf8b2d6796c7941a31795cd2cb55eb3.tar.gz | |
sync with Context as of 2013-06-09
Diffstat (limited to 'lualibs-util-prs.lua')
| -rw-r--r-- | lualibs-util-prs.lua | 16 | 
1 files changed, 15 insertions, 1 deletions
| diff --git a/lualibs-util-prs.lua b/lualibs-util-prs.lua index 9d2ffcc..9b2a2b0 100644 --- a/lualibs-util-prs.lua +++ b/lualibs-util-prs.lua @@ -9,8 +9,9 @@ if not modules then modules = { } end modules ['util-prs'] = {  local lpeg, table, string = lpeg, table, string  local P, R, V, S, C, Ct, Cs, Carg, Cc, Cg, Cf, Cp = lpeg.P, lpeg.R, lpeg.V, lpeg.S, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg, lpeg.Cc, lpeg.Cg, lpeg.Cf, lpeg.Cp  local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns -local concat, format, gmatch, find = table.concat, string.format, string.gmatch, string.find +local concat, gmatch, find = table.concat, string.gmatch, string.find  local tostring, type, next, rawset = tostring, type, next, rawset +local mod, div = math.mod, math.div  utilities         = utilities or {}  local parsers     = utilities.parsers or { } @@ -590,3 +591,16 @@ end  -- }  --  -- inspect(utilities.parsers.mergehashes(t,"aa, bb, cc")) + +function utilities.parsers.runtime(time) +    if not time then +        time = os.runtime() +    end +    local days = div(time,24*60*60) +    time = mod(time,24*60*60) +    local hours = div(time,60*60) +    time = mod(time,60*60) +    local minutes = div(time,60) +    local seconds = mod(time,60) +    return days, hours, minutes, seconds +end | 
