You are not logged in.
I've been fiddeling around with my rc.lua again and have attempted to get a world clock going when I right-click on my clockwidget.
It's working all right and pretty much serves my purpose, but I was wondering if there's a more elegant way of doing this, as I'm not a programmer and put this together with a lot of guess work. Couldn't find anything online.
Also, if there is a more elegant way, can it take care of daylight saving in the different zones as well (don't bother if this requires too much coding)?
Here's what I did (just calculates the time difference between my time zone (EAST) and the others I need:
local function time_cet()
local time = os.time()
time2 = time - (8*3600)
local new_time = os.date("%a, %I:%M%P", time2)
return new_time
end
local function time_utc()
local time = os.time()
time2 = time - (9*3600)
local new_time = os.date("%a, %I:%M%P", time2)
return new_time
end
local function time_nzst()
local time = os.time()
time2 = time + (2*3600)
local new_time = os.date("%a, %I:%M%P", time2)
return new_time
end
local function time_ckt()
local time = os.time()
time2 = time - (20*3600)
local new_time = os.date("%a, %I:%M%P", time2)
return new_time
end
local function time_pst()
local time = os.time()
time2 = time - (17*3600)
local new_time = os.date("%a, %I:%M%P", time2)
return new_time
end
local function time_est()
local time = os.time()
time2 = time - (14*3600)
local new_time = os.date("%a, %I:%M%P", time2)
return new_time
end
clockwidget:buttons(awful.util.table.join(awful.button({}, 3, function () naughty.notify({ text = "London : " .. time_utc() .. "\nDüsseldorf: " .. time_cet() .. "\n\nTauranga : " .. time_nzst() .. "\nRarotonga : " .. time_ckt() .. "\n\nVancouver : " .. time_pst() .. "\nWoods Hole: " .. time_est() .. "", timeout = 10, hover_timeout = 0.5 }) end)))
Thanks very much.
Last edited by JackH79 (2010-07-17 04:07:57)
Offline