1
0
mirror of https://github.com/ShadowKatStudios/OC-Minitel.git synced 2024-11-09 20:08:06 +11:00
OC-Minitel/realtime/OpenOS/usr/lib/realtime.lua

23 lines
556 B
Lua
Raw Normal View History

local computer = require "computer"
local realtime = {}
realtime.epoch, realtime.uptime, realtime.offset = 0, computer.uptime(), 0
function realtime.update(epoch,uptime,offset)
if type(epoch) ~= "number" or type(uptime) ~= "number" then
return false
end
realtime.epoch, realtime.uptime, realtime.offset = epoch, uptime, offset or realtime.offset
return true
end
function realtime.time(utc)
local ofs = realtime.offset
if utc then
ofs = 0
end
local ut = computer.uptime()
return (realtime.epoch+(ut-realtime.uptime))+ofs
end
return realtime