Advertisement
Guest User

lib.lua

a guest
Apr 17th, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.98 KB | None | 0 0
  1. local component = require("component")
  2. local fs = require("filesystem")
  3.  
  4. local timenew = {}
  5.  
  6. TIMEZONE = 0
  7. CORRECT  = 0
  8.  
  9. tz = TIMEZONE + CORRECT
  10. local t_correction = tz * 3600
  11. local function getTime()
  12.     local file = io.open('/tmp/clock.dt', 'w')
  13.     file:write('')
  14.     file:close()
  15.     local lastmod = tonumber(string.sub(fs.lastModified('/tmp/clock.dt'), 1, -4)) + t_correction
  16.     local modp = tonumber(string.sub(fs.lastModified('/tmp/clock.dt'), 1, -4)) -(3*3600)
  17.    -- local dt = os.date('%Y.%m.%d %H:%M:%S', lastmod)
  18.     local dt = os.date('%H:%M:%S', lastmod)
  19.     local dtp = os.date('%H:%M:%S', modp)
  20.     return dt,dtp
  21. end
  22.  
  23. function timenew.TimeScreen(str)
  24. while true do
  25. local dt, dtp = getTime()
  26. local formattimeN= "Нск - "..dt.."   "
  27. local formattimeP= "Спб - "..dtp
  28. local screentime=component.screen_controller
  29. screentime.clearText(str)
  30. screentime.addText(str, formattimeN, 0x00ff00)
  31. screentime.addText(str, formattimeP, 0x0000ff)
  32. print (dt,dtp)
  33. os.sleep(1)
  34. end
  35. end
  36. return timenew
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement