return function(ctx) if not ctx:authenticated() then return end -- Handle browser sync POST if ctx.headers.method == "POST" then local epoch = tonumber(ctx.postdata.epoch) local tz = tonumber(ctx.postdata.tz) if epoch then time.set(epoch) end if tz then time.settimezone(tz) end end -- Read current time local epoch = time.get() local valid = epoch and epoch > 1600000000 local timestr = "TIME NOT SET" if valid then local t = time.getlocal() timestr = string.format( "%04d-%02d-%02d %02d:%02d:%02d", t.year, t.mon, t.day, t.hour, t.min, t.sec ) end -- Send HTML ctx:send(ctx.http_preamble) ctx:send([[ System Time

Status page | System control

]]) if valid then ctx:send('
Current Device Time:
') ctx:send('

' .. timestr .. '

') ctx:send('
') ctx:send('') else ctx:send('
SYSTEM TIME NOT SET
') ctx:send('

Please sync time from your phone.

') ctx:send('
') ctx:send('') end ctx:send([[ ]]) end