2021-01-08 13:32:55 +00:00
|
|
|
local internet = require("internet")
|
2021-01-08 14:06:36 +00:00
|
|
|
local component = require("component")
|
|
|
|
local modem = component.modem
|
|
|
|
|
|
|
|
modem.open(69)
|
2021-01-08 13:32:55 +00:00
|
|
|
|
|
|
|
while true do
|
|
|
|
local handle = internet.request("http://worldclockapi.com/api/json/utc/now")
|
|
|
|
local result = ""
|
|
|
|
for chunk in handle do
|
|
|
|
result = result..chunk
|
|
|
|
end
|
|
|
|
local f = io.open("time.txt", "w")
|
2021-01-08 13:33:43 +00:00
|
|
|
f:write(result)
|
2021-01-08 13:50:10 +00:00
|
|
|
f:close()
|
2021-01-08 13:50:34 +00:00
|
|
|
f = io.open("time.txt", "r")
|
2021-01-08 13:55:57 +00:00
|
|
|
f:seek("set", 30)
|
|
|
|
local date = f:read(10)
|
|
|
|
f:seek("set", 41)
|
|
|
|
local hour = tonumber(f:read(2)) + 3
|
|
|
|
f:seek("set", 44)
|
|
|
|
local min = f:read(2)
|
2021-01-08 13:32:55 +00:00
|
|
|
f:close()
|
2021-01-08 14:06:36 +00:00
|
|
|
local datetime = date.." "..hour..":"..min
|
|
|
|
print(datetime)
|
2021-01-08 14:23:28 +00:00
|
|
|
modem.broadcast(69, datetime)
|
2021-01-08 13:32:55 +00:00
|
|
|
end
|