From 2bd3b6a3c5ca274e4b01d934c4a3ce6d71fbb7ff Mon Sep 17 00:00:00 2001 From: erius0 <63460770+erius0@users.noreply.github.com> Date: Fri, 8 Jan 2021 17:40:53 +0300 Subject: [PATCH] Update getTime.lua --- getTime.lua | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/getTime.lua b/getTime.lua index 3382464..652f80a 100644 --- a/getTime.lua +++ b/getTime.lua @@ -1,22 +1,16 @@ 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 - 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 - 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) +for chunk in handle do + 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)