From e51d8ac39e67fdbd5ce26c024f1a85497dc7bc86 Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Mon, 4 Oct 2010 22:42:31 +0200 Subject: date: turn time widget argument into an offset The os.time() call should not be passed as an argument it self, because of a chance it will be stored internally and so we would always get the same time. Instead we can pass time offsets in seconds, i.e. to go 6 hours forward we can use the widget argument 21600, to go 6 hours back we use -21600 instead. --- widgets/date.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'widgets') diff --git a/widgets/date.lua b/widgets/date.lua index b20e43f..d3c6ce9 100644 --- a/widgets/date.lua +++ b/widgets/date.lua @@ -5,8 +5,11 @@ --------------------------------------------------- -- {{{ Grab environment -local os = { date = os.date } local setmetatable = setmetatable +local os = { + date = os.date, + time = os.time +} -- }}} @@ -16,7 +19,7 @@ module("vicious.widgets.date") -- {{{ Date widget type local function worker(format, warg) - return os.date(format or nil, warg or nil) + return os.date(format or nil, warg and os.time()+warg or nil) end -- }}} -- cgit v1.2.3