aboutsummaryrefslogtreecommitdiff
path: root/uptime.lua
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2009-10-05 00:10:47 +0200
committerAdrian C. (anrxc) <anrxc@sysphere.org>2009-10-05 00:10:47 +0200
commit4602ca2fa5e8e2e408713f72ae7e4cd14480bc01 (patch)
treebfbf75b8afd738f5a036737404f3eafe87586c66 /uptime.lua
parentaf4e85f99d0ac63127f19640ef47d768d7bed7cd (diff)
downloadvicious-legacy-4602ca2fa5e8e2e408713f72ae7e4cd14480bc01.tar.xz
Lots of coding style changes
Diffstat (limited to 'uptime.lua')
-rw-r--r--uptime.lua13
1 files changed, 7 insertions, 6 deletions
diff --git a/uptime.lua b/uptime.lua
index 50bc179..712bb14 100644
--- a/uptime.lua
+++ b/uptime.lua
@@ -9,6 +9,7 @@ local tonumber = tonumber
local io = { open = io.open }
local setmetatable = setmetatable
local math = { floor = math.floor }
+local string = { match = string.match }
-- }}}
@@ -23,13 +24,13 @@ local function worker(format)
local line = f:read("*line")
f:close()
- local total_uptime = math.floor(tonumber(line:match("[%d%.]+")))
- local uptime_days = math.floor(total_uptime / (3600 * 24))
- local uptime_hours = math.floor((total_uptime % (3600 * 24)) / 3600)
- local uptime_minutes = math.floor(((total_uptime % (3600 * 24)) % 3600) / 60)
- local uptime_seconds = math.floor(((total_uptime % (3600 * 24)) % 3600) % 60)
+ local up_t = math.floor(tonumber(string.match(line, "[%d%.]+")))
+ local up_d = math.floor(up_t / (3600 * 24))
+ local up_h = math.floor((up_t % (3600 * 24)) / 3600)
+ local up_m = math.floor(((up_t % (3600 * 24)) % 3600) / 60)
+ local up_s = math.floor(((up_t % (3600 * 24)) % 3600) % 60)
- return {total_uptime, uptime_days, uptime_hours, uptime_minutes, uptime_seconds}
+ return {up_t, up_d, up_h, up_m, up_s}
end
-- }}}