Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --3-letter time zone code
- timezone="est"
- --Do you want 24-hour time?
- militarytime=false
- --Colors
- ctime="white"
- campm="white"
- cbg="black"
- --Don't touch the rest or it may break
- --Formatting Variables
- ampm=""
- m = peripheral.wrap("right")
- m.setTextScale(4)
- function extract()
- timelong=nil
- timelong=timelonge.readAll()
- end
- while true do
- timelonge=http.get("http://www.timeapi.org/"..timezone)
- repeat
- pcall(extract)
- until timelong~=nil
- hour=tonumber(string.sub(timelong,12,13,"%0"))
- minute=tonumber(string.sub(timelong,15,16,"%0"))
- if militarytime==false then
- if hour>12 then
- hour=hour-12
- ampm="PM"
- else
- ampm="AM"
- end
- if hour==0 then
- hour=12
- end
- end
- if hour<10 then
- hours=" "..tostring(hour)
- else
- hours=tostring(hour)
- end
- minutes=tostring(minute)
- if minute<10 then
- minutes="0"..tostring(minute)
- end
- time=hours..":"..minutes.." "..ampm
- timeold=time
- if time~=oldtime then
- m.clear()
- m.setCursorPos(1,1)
- m.write(" "..time)
- end
- sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment