Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --pastebin run tqaNepSZ
- -- ======машинное время (время хоста)=======
- -- раскомментируйте библиотеку, если она не подключена в вашем коде
- local fs = require("filesystem")
- local component = require("component")
- local gpu = component.gpu
- local TIME_ZONE = 0
- local t_correction = TIME_ZONE * 3600
- local function get_date_from_unix(unix_time)
- unix_time = unix_time + t_correction
- local day_count, year, days, month = function(yr) return (yr % 4 == 0 and (yr % 100 ~= 0 or yr % 400 == 0)) and 366 or 365 end, 1970, math.ceil(unix_time/86400)
- while days >= day_count(year) do
- days = days - day_count(year) year = year + 1
- end
- local tab_overflow = function(seed, table) for i = 1, #table do if seed - table[i] <= 0 then return i, seed end seed = seed - table[i] end end
- month, days = tab_overflow(days, {31,(day_count(year) == 366 and 29 or 28),31,30,31,30,31,31,30,31,30,31})
- local hours, minutes, seconds = math.floor(unix_time / 3600 % 24), math.floor(unix_time / 60 % 60), math.floor(unix_time % 60)
- return hours+3, minutes, seconds,days, month, year
- end
- local function getTimeHost()
- local file = io.open('/tmp/unix.tmp', 'w')
- file:write('')
- file:close()
- --print( os.date(os.date("*t", fs.lastModified('/tmp/unix.tmp')/1000 )))
- --print(fs.lastModified('/tmp/unix.tmp')/1000)
- return string.format("%d:%d:%d %d/%d/%d",get_date_from_unix(fs.lastModified('/tmp/unix.tmp')/1000))
- end
- gpu.setResolution(string.len(getTimeHost()),1)
- while true do
- gpu.set(1,1,getTimeHost())
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement