Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function _getTime(format)
- local response = http.post(
- "http://www.imgood.webege.com/time.php",
- "format="..textutils.urlEncode(format)
- )
- return response:readLine()
- end
- local function getTime()
- local start = _getTime("h:i:s")
- sleep(1)
- local stop = _getTime("h:i:s - D, M d, Y - T")
- print(start..", "..stop)
- local hs, ms, ss = string.match(start, "(%d+):(%d+):(%d+)")
- local he, me, se, date, timezone = string.match(stop, "^(%d-):(%d-):(%d-)%s?-%s?([%w,%s]-)%s?-%s?(%w+)$")
- print(tostring(he)..", "..tostring(me))
- hs, ms, ss, he, me, se = tonumber(hs), tonumber(ms), tonumber(ss), tonumber(he), tonumber(me), tonumber(se)
- local startSec = ss + ((ms + (hs * 60)) * 60)
- local endSec = se + ((me + (he * 60)) * 60)
- return endSec - startSec, he, me, se, date, timezone
- end
- local function addZero(n)
- if tostring(n):len() == 1 then
- return "0"..tostring(n)
- else
- return tostring(n)
- end
- end
- while true do
- local sec, h, m, s, date, timezone = getTime()
- for i = 1, 10 do
- for i=1, 60 do
- term.clear()
- term.setCursorPos(2, 2)
- print(h..":"..addZero(m)..":"..addZero(s).." "..timezone.." - "..date)
- sleep(sec)
- s = s + 1
- if s >= 60 then
- s = 0
- m = m + 1
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement