Update getTime.lua

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

View file

@ -5,7 +5,7 @@ local modem = component.modem
modem.open(69)
while true do
local handle = internet.request("http://worldclockapi.com/api/json/utc/now")
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
@ -14,14 +14,9 @@ while true do
f:write(result)
f:close()
f = io.open("time.txt", "r")
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)
f:seek("set", 245)
local time = f:read(19)
f:close()
local datetime = date.." "..hour..":"..min
print(datetime)
modem.broadcast(69, datetime)
print(time)
--modem.broadcast(69, time)
end