From 4602ca2fa5e8e2e408713f72ae7e4cd14480bc01 Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Mon, 5 Oct 2009 00:10:47 +0200 Subject: Lots of coding style changes --- uptime.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'uptime.lua') 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 -- }}} -- cgit v1.2.3