Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Time API
- if not switchcraft then
- os.loadAPI("json")
- end
- --timezone is for an example: Europe/Helsinki
- function getTime(timezone, x, y)
- local obj = http.get("http://worldtimeapi.org/api/timezone/"..timezone).readAll()
- local tbl = json.decode(obj)
- local ts = tbl.unixtime+tbl.dst_offset
- term.clearLine()
- x,y = term.getCursorPos()
- term.setCursorPos(x,y)
- term.write(os.date('%Y-%m-%d %H:%M:%S', ts))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement