Module:Clock

-- local p = {}

local green = '3px inset #0F0' local black = '3px solid #000'

local display = { [':'] = {		{ top = green, right = black, bottom = black, left = black }, { top = black, right = black, bottom = green, left = black } },	[0] = {		{ top = green, right = green, bottom = black, left = green }, { top = black, right = green, bottom = green, left = green } },	[1] = {		{ top = black, right = green, bottom = black, left = black }, { top = black, right = green, bottom = black, left = black } },	[2] = {		{ top = green, right = green, bottom = green, left = black }, { top = black, right = black, bottom = green, left = green } },	[3] = {		{ top = green, right = green, bottom = black, left = black }, { top = green, right = green, bottom = green, left = black } },	[4] = {		{ top = black, right = green, bottom = green, left = green }, { top = black, right = green, bottom = black, left = black } },	[5] = {		{ top = green, right = black, bottom = black, left = green }, { top = green, right = green, bottom = green, left = black } },	[6] = {		{ top = green, right = black, bottom = black, left = green }, { top = green, right = green, bottom = green, left = green } },	[7] = {		{ top = green, right = green, bottom = black, left = green }, { top = black, right = green, bottom = black, left = black } },	[8] = {		{ top = green, right = green, bottom = green, left = green }, { top = black, right = green, bottom = green, left = green } },	[9] = {		{ top = green, right = green, bottom = green, left = green }, { top = black, right = green, bottom = green, left = black } } }

function p.main local time = os.date('*t') local h,m,s = time.hour, time.min, time.sec

local h1,h2 = math.floor(h/10),h%10 local m1,m2 = math.floor(m/10),m%10 local s1,s2 = math.floor(s/10),s%10

local tbl = { h1, h2, ':', m1, m2, ':', s1, s2 }

local size = 20 local height = size * 2 + 9 local numwidth = size + 6 local colwidth = 3 local ret = mw.html.create('table') :css({ background = '#000',					padding = '10px' })

local newrow = ret:tag('tr')

for _, v in ipairs(tbl) do		local _w if tonumber(v) then _w = numwidth else _w = colwidth end local borders = {} for x, y in pairs(display[v][1]) do			borders['border'..x] = y		end newrow	:tag('td') :css({ width = _w,					height = height }) :css(borders) :done end

newrow:done newrow = ret:tag('tr')

for _, v in ipairs(tbl) do		local _w if tonumber(v) then _w = numwidth else _w = colwidth end local borders = {} for x, y in pairs(display[v][2]) do			borders['border'..x] = y		end newrow	:tag('td') :css({ width = _w,					height = height }) :css(borders) :done end

ret:allDone return ret end

return p