]> git.decadent.org.uk Git - ion3.git/blob - utils/ion-statusd/statusd_date.lua
Imported Upstream version 20090110
[ion3.git] / utils / ion-statusd / statusd_date.lua
1 --
2 -- ion/mod_statusbar/ion-statusd/statusd_date.lua
3 -- 
4 -- Copyright (c) Tuomo Valkonen 2004-2009.
5 --
6 -- See the included file LICENSE for details.
7 --
8
9
10 local timer
11
12 local defaults={
13     date_format='%a %Y-%m-%d %H:%M',
14     formats={},
15 }
16
17 local settings=table.join(statusd.get_config('date'), defaults)
18
19 local function update()
20     local tm=os.time()
21     statusd.inform('date', os.date(settings.date_format, tm))
22     for k, f in pairs(settings.formats) do
23         statusd.inform('date_'..k, os.date(f, tm))
24     end
25     return tm
26 end
27
28 local function timer_handler(tmr)
29     local tm=update()
30     
31     local t=os.date('*t', tm)
32     local d=(60-t.sec)*1000
33     
34     timer:set(d, timer_handler)
35 end
36
37 timer=statusd.create_timer()
38 timer_handler(timer)