From 6113b3da564edbbd5ab9e8866be7faf587788ca3 Mon Sep 17 00:00:00 2001 From: erius0 <63460770+erius0@users.noreply.github.com> Date: Fri, 8 Jan 2021 17:38:47 +0300 Subject: [PATCH] Update getTime.lua --- getTime.lua | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/getTime.lua b/getTime.lua index 1bf54e9..3382464 100644 --- a/getTime.lua +++ b/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