Update getTime.lua
This commit is contained in:
parent
924cfdbb1f
commit
6113b3da56
1 changed files with 5 additions and 10 deletions
15
getTime.lua
15
getTime.lua
|
@ -5,7 +5,7 @@ local modem = component.modem
|
||||||
modem.open(69)
|
modem.open(69)
|
||||||
|
|
||||||
while true do
|
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 = ""
|
local result = ""
|
||||||
for chunk in handle do
|
for chunk in handle do
|
||||||
result = result..chunk
|
result = result..chunk
|
||||||
|
@ -14,14 +14,9 @@ while true do
|
||||||
f:write(result)
|
f:write(result)
|
||||||
f:close()
|
f:close()
|
||||||
f = io.open("time.txt", "r")
|
f = io.open("time.txt", "r")
|
||||||
f:seek("set", 30)
|
f:seek("set", 245)
|
||||||
local date = f:read(10)
|
local time = f:read(19)
|
||||||
f:seek("set", 41)
|
|
||||||
local hour = tonumber(f:read(2)) + 3
|
|
||||||
f:seek("set", 44)
|
|
||||||
local min = f:read(2)
|
|
||||||
f:close()
|
f:close()
|
||||||
local datetime = date.." "..hour..":"..min
|
print(time)
|
||||||
print(datetime)
|
--modem.broadcast(69, time)
|
||||||
modem.broadcast(69, datetime)
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue