jfmachine

getIRLtime

Jun 7th, 2023
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. if not http then error("no http") end
  2. local httpResponseHandle = http.get("http://artemix.hu/cctime.php?timezone=FOR_GODS_SAKE_SET_THIS_TO_SOMETHING")
  3. if not httpResponseHandle then error("error fetching time") end
  4. local timeTable = textutils.unserialize(httpResponseHandle.readAll())
  5. httpResponseHandle.close()
  6. local hour = timeTable.h
  7. local minute = timeTable.m
  8. local second = timeTable.s
  9.  
  10. local interval = 1
  11. while true do
  12. sleep(interval)
  13. second = second + interval
  14. if not (second < 60) then
  15. second = second - 60
  16. minute = minute + 1
  17. end
  18. if not (minute < 60) then
  19. minute = minute - 60
  20. hour = hour + 1
  21. end
  22. if not (hour < 24) then
  23. hour = hour - 24
  24. end
  25. print(string.format("%02d:%02d:%02d", hour, minute, second))
  26. end
Add Comment
Please, Sign In to add comment