Streetboy_xD

[Computercraft] Datum (German)

Nov 5th, 2014
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. function switchdate(word)
  2.  
  3. if word == "" then
  4.  
  5. return "nil"
  6.  
  7. else
  8.  
  9. _newword = ""
  10.  
  11. _year = string.sub(word,1,4)
  12. _month = string.sub(word,6,7)
  13. _day = string.sub(word,9,10)
  14.  
  15. _newword = _day..".".._month..".".._year
  16.  
  17. return _newword
  18.  
  19. end
  20.  
  21. end
  22.  
  23.  
  24. function correcttime(_time)
  25.  
  26. if _time == "" then
  27.  
  28. return "nil"
  29.  
  30. else
  31.  
  32. _newtime = ""
  33.  
  34. _hour = string.sub(_time,1,2)
  35. _hour = tonumber(_hour)
  36. _hour = _hour + 1
  37. _hour = tostring(_hour)
  38.  
  39. _minute = string.sub(_time,4,5)
  40. _second = string.sub(_time,7,8)
  41.  
  42. _newtime = _hour..":".._minute..":".._second
  43.  
  44. return _newtime
  45.  
  46. end
  47.  
  48. end
  49.  
  50. term.clear()
  51.  
  52. zeitlink = "http://www.timeapi.org/utc/now"
  53.  
  54. time = http.get(zeitlink)
  55.  
  56. if not http.get("http://example.com/") then
  57.  
  58. term.clear()
  59. term.setCursorPos(1,1)
  60. term.write("Konnte keine Verbindung herstellen!")
  61.  
  62. else
  63.  
  64. readedtime = time.readAll()
  65.  
  66. term.setCursorPos(1,1)
  67. term.write("Heute ist der "..switchdate(string.sub(readedtime,1,10)))
  68. term.setCursorPos(1,2)
  69. term.write("Es ist: "..correcttime(string.sub(readedtime,12,19)))
  70.  
  71. end
Advertisement
Add Comment
Please, Sign In to add comment