From 97dcd6acfb0fcdadd00a13a4196607332ecefe4e Mon Sep 17 00:00:00 2001 From: erius0 <63460770+erius0@users.noreply.github.com> Date: Fri, 8 Jan 2021 03:08:54 +0300 Subject: [PATCH] Update linkedGet.lua --- linkedGet.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/linkedGet.lua b/linkedGet.lua index f8e29af..87a9e3b 100644 --- a/linkedGet.lua +++ b/linkedGet.lua @@ -5,19 +5,20 @@ local fs = require("filesystem") local tunnel = component.tunnel local TIME_ZONE = 2 local t_correction = TIME_ZONE * 3600 -local function getTimeHost() - local file = io.open('/tmp/unix.tmp', 'w') - file:write('') - file:close() - local lastmod = tonumber(string.sub(fs.lastModified('UNIX.tmp'), 1, -4)) + t_correction - local date = os.date('%x', lastmod) - local time = os.date('%X', lastmod) - local dt = os.date('%Y.%m.%d %H:%M:%S', lastmod) - return dt +function os.dateRL(format) + if not fs.get("/").isReadOnly() then + local time = io.open("/tmp/.time", "w") + time:write() + time:close() + os.sleep(0.01) + return os.date(format, fs.lastModified("/tmp/.time") / 1002.7) + else + return os.date(format) + end end while true do local _, _, _, _, _, message = event.pull("modem_message") - local date = getTimeHost() + local date = os.dateRL("%x %X") print("[ "..date.." ]"..message) tunnel.send("succes!") end