Advertisement
HarvDad

timer

Jun 6th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. --time = os.time() print("time= ", time)
  2.  
  3. clockTime = os.clock()
  4. print("clockTime: ", clockTime, ", minutes: ", clockTime / 60)
  5.  
  6. fakeTime = 33.4567
  7.  
  8.  
  9. function displayTime(time)
  10. --print("time = ", time)
  11. rawSeconds = math.floor(time)
  12. rawMinutes = math.floor(rawSeconds/60)
  13. hours = math.floor(rawMinutes/60)
  14. seconds = rawSeconds - (rawMinutes * 60)
  15. minutes = rawMinutes - (hours * 60)
  16.  
  17. -- print("Raw: ", hours, "h ", rawMinutes, "m ", rawSeconds, "s")
  18. -- print(hours, "h ", minutes, "m ", seconds, "s")
  19.  
  20. timeString = "Elapsed time: "
  21.  
  22. hStr = " hrs "
  23. mStr = " mins "
  24. sStr = " secs"
  25.  
  26. if hours == 1 then hStr = " hr " end
  27. if minutes == 1 then mStr = " min " end
  28. if seconds == 1 then sStr = " sec " end
  29.  
  30. if hours > 0 then
  31. timeString = timeString .. hours .. hStr
  32. end
  33. if minutes > 0 then
  34. timeString = timeString .. minutes .. mStr
  35. end
  36. if seconds > 0 then
  37. timeString = timeString .. seconds .. sStr
  38. end
  39.  
  40. print(timeString)
  41. end
  42.  
  43. --[[
  44. formattedTime = textutils.formatTime(timeNumber, true)
  45. print("formattedTime: ", formattedTime)
  46.  
  47. elapsedTime = 12.706 - 11.637
  48. print("elapsedTime: ", textutils.formatTime(elapsedTime, true))
  49. --]]
  50.  
  51. --print("Elapsed time: ")
  52. --displayTime(915432.4567)
  53.  
  54. print("Time since last reboot:")
  55. displayTime(clockTime)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement