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)
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue