This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
YSPilot's profile picture

Real Time Clock

Started by YSPilot, 13 May 2013 - 06:37 PM
YSPilot #1
Posted 13 May 2013 - 08:37 PM
It is important that you have HTTP enabled to use this, as there is not built in API for getting system time. Use the Pastebin command, if it doesn't work, this will not work on your monitor.

You will need to manually edit the peripheral to your setup.

Inform me if I have missed a timezone, and I will add it as soon as possible! Enjoy!

Eastern Standard Time:
Spoiler

ymon = peripheral.wrap("right")
ymon.setTextScale(6)
term.redirect(ymon)
while true do
sleep(1)
term.setCursorPos(1,1)
write(http.get("http://www.timeapi.org/est/now?format=%20%25I:%25M:%25S").readAll())
end
term.restore()


Eastern Standard Time (Daylight Savings):
Spoiler

ymon = peripheral.wrap("right")
ymon.setTextScale(6)
term.redirect(ymon)
while true do
sleep(1)
term.setCursorPos(1,1)
write(http.get("http://www.timeapi.org/est/in+one+hour?format=%20%25I:%25M:%25S").readAll())
end
term.restore()

Greenwich Mean Time / Coordinated Universal Time:
Spoiler

ymon = peripheral.wrap("right")
ymon.setTextScale(6)
term.redirect(ymon)
while true do
sleep(1)
term.setCursorPos(1,1)
write(http.get("http://www.timeapi.org/utc/now?format=%20%25I:%25M:%25S").readAll())
end
term.restore()


Central Standard Time:
Spoiler

ymon = peripheral.wrap("right")
ymon.setTextScale(6)
term.redirect(ymon)
while true do
sleep(1)
term.setCursorPos(1,1)
write(http.get("http://www.timeapi.org/cst/now?format=%20%25I:%25M:%25S").readAll())
end
term.restore()


Central Standard Time (Daylight Savings):
Spoiler

ymon = peripheral.wrap("right")
ymon.setTextScale(6)
term.redirect(ymon)
while true do
sleep(1)
term.setCursorPos(1,1)
write(http.get("http://www.timeapi.org/cst/in+one+hour?format=%20%25I:%25M:%25S").readAll())
end
term.restore()

Pacific Daylight Time:
Spoiler

ymon = peripheral.wrap("right")
ymon.setTextScale(6)
term.redirect(ymon)
while true do
sleep(1)
term.setCursorPos(1,1)
write(http.get("http://www.timeapi.org/pdt/in+one+hour?format=%20%25I:%25M:%25S").readAll())
end
term.restore()

Hawaii–Aleutian Time Zone:
Spoiler

ymon = peripheral.wrap("right")
ymon.setTextScale(6)
term.redirect(ymon)
while true do
sleep(1)
term.setCursorPos(1,1)
write(http.get("http://www.timeapi.org/hast/in+one+hour?format=%20%25I:%25M:%25S").readAll())
end
term.restore()

Alaskan Standard Time:
Spoiler

ymon = peripheral.wrap("right")
ymon.setTextScale(6)
term.redirect(ymon)
while true do
sleep(1)
term.setCursorPos(1,1)
write(http.get("http://www.timeapi.org/akst/in+one+hour?format=%20%25I:%25M:%25S").readAll())
end
term.restore()

Mountian Standard Time:
Spoiler

ymon = peripheral.wrap("right")
ymon.setTextScale(6)
term.redirect(ymon)
while true do
sleep(1)
term.setCursorPos(1,1)
write(http.get("http://www.timeapi.org/mst/now?format=%20%25I:%25M:%25S").readAll())
end
term.restore()


Mountian Standard Time (Daylight Savings):
Spoiler

ymon = peripheral.wrap("right")
ymon.setTextScale(6)
term.redirect(ymon)
while true do
sleep(1)
term.setCursorPos(1,1)
write(http.get("http://www.timeapi.org/mst/in+one+hour?format=%20%25I:%25M:%25S").readAll())
end
term.restore()

Central Europe Time:
Spoiler

ymon = peripheral.wrap("right")
ymon.setTextScale(6)
term.redirect(ymon)
while true do
sleep(1)
term.setCursorPos(1,1)
write(http.get("http://www.timeapi.org/cet/now?format=%20%25I:%25M:%25S").readAll())
end
term.restore()


Central Europe Time(Daylight Savings):
Spoiler

ymon = peripheral.wrap("right")
ymon.setTextScale(6)
term.redirect(ymon)
while true do
sleep(1)
term.setCursorPos(1,1)
write(http.get("http://www.timeapi.org/cet/now?format=%20%25I:%25M:%25S").readAll())
end
term.restore()
Molinko #2
Posted 14 May 2013 - 03:26 AM
This is awesome! Dare I say, it could be a little fancier?
Anywhoo, i love the time api site. Never knew that existed :3
Mackan90096 #3
Posted 14 May 2013 - 10:36 AM
Wheres the GMT ?

Other than that. Great "apis"
YSPilot #4
Posted 19 May 2013 - 07:25 PM
Thank, ill ad the GMT here in a bit, I'm working on a change for my stripmine script.

Note that GMT is the same time as UTC.
Mackan90096 #5
Posted 20 May 2013 - 02:09 AM
:)/>
Majd Alfhaily #6
Posted 20 May 2013 - 11:16 AM
heh, really cool idea. Simple but efficient!
YSPilot #7
Posted 22 May 2013 - 04:12 PM
Thanks! :D/>