158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
function fn.timespec(n)
if n == 0 then return '0s' end
if n < 0 then return '-' .. fn.timespec(n*-1) end
local sec = math.floor(n % 60)
local min = math.floor(n / 60)
local hr = math.floor(min / 60)
local spec = {}
if hr ~= 0 then table.insert(spec, string.format("%shr", hr)) end
if min ~= 0 then table.insert(spec, string.format("%sm", min)) end
if sec ~= 0 then table.insert(spec, string.format("%ss", sec)) end
return table.concat(spec, ' ')
end
return fn
|
|
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
function fn.timespec(n)
if n == 0 then return '0s' end
if n < 0 then return '-' .. fn.timespec(n*-1) end
local sec = math.floor(n % 60)
local min = math.floor(n / 60)
local hr = math.floor(min / 60)
min = min % 60
local spec = {}
if hr ~= 0 then table.insert(spec, string.format("%shr", hr)) end
if min ~= 0 then table.insert(spec, string.format("%sm", min)) end
if sec ~= 0 then table.insert(spec, string.format("%ss", sec)) end
return table.concat(spec, ' ')
end
return fn
|