Update linkedGet.lua

This commit is contained in:
erius0 2021-01-08 03:08:54 +03:00 committed by GitHub
parent c8ac167947
commit 97dcd6acfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,19 +5,20 @@ local fs = require("filesystem")
local tunnel = component.tunnel local tunnel = component.tunnel
local TIME_ZONE = 2 local TIME_ZONE = 2
local t_correction = TIME_ZONE * 3600 local t_correction = TIME_ZONE * 3600
local function getTimeHost() function os.dateRL(format)
local file = io.open('/tmp/unix.tmp', 'w') if not fs.get("/").isReadOnly() then
file:write('') local time = io.open("/tmp/.time", "w")
file:close() time:write()
local lastmod = tonumber(string.sub(fs.lastModified('UNIX.tmp'), 1, -4)) + t_correction time:close()
local date = os.date('%x', lastmod) os.sleep(0.01)
local time = os.date('%X', lastmod) return os.date(format, fs.lastModified("/tmp/.time") / 1002.7)
local dt = os.date('%Y.%m.%d %H:%M:%S', lastmod) else
return dt return os.date(format)
end
end end
while true do while true do
local _, _, _, _, _, message = event.pull("modem_message") local _, _, _, _, _, message = event.pull("modem_message")
local date = getTimeHost() local date = os.dateRL("%x %X")
print("[ "..date.." ]"..message) print("[ "..date.." ]"..message)
tunnel.send("succes!") tunnel.send("succes!")
end end