Update getTime.lua

This commit is contained in:
erius0 2021-01-08 17:40:53 +03:00 committed by GitHub
parent 6113b3da56
commit 2bd3b6a3c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,22 +1,16 @@
local internet = require("internet") local internet = require("internet")
local component = require("component")
local modem = component.modem
modem.open(69) local handle = internet.request("http://api.timezonedb.com/v2.1/get-time-zone?key=INWE0H77BDN6&by=zone&zone=Europe/Moscow&format=json")
local result = ""
while true do for chunk in handle do
local handle = internet.request("http://api.timezonedb.com/v2.1/get-time-zone?key=INWE0H77BDN6&by=zone&zone=Europe/Moscow&format=json")
local result = ""
for chunk in handle do
result = result..chunk result = result..chunk
end
local f = io.open("time.txt", "w")
f:write(result)
f:close()
f = io.open("time.txt", "r")
f:seek("set", 245)
local time = f:read(19)
f:close()
print(time)
--modem.broadcast(69, time)
end end
local f = io.open("time.txt", "w")
f:write(result)
f:close()
f = io.open("time.txt", "r")
f:seek("set", 245)
local time = f:read(19)
f:close()
print(time)