Module:Sandbox/MonkeysHK/2

require('Module:LoadLib')(_G)

-- Set exports local skydate = {}

function skydate:create(settings) local methods = {} local skyblock_epoch = 1560275700 function constructor(self, settings) if not settings then self.unix = os.date("!*t") -- current time else -- settings can be a string or a table of values -- settings can be a SkyBlock time or an Earth time self:_parseSkyDate(settings) end self:_unixConvert return self end function methods:_parseSkyDate(self, str) -- prepares self.unix end function methods:_unixConvert(self) -- Arithmetic Breakdown: -- 1 y = 12 mo = 372 d = 8928 h = 535680 m = 32140800 s		-- 1 mo = 31 d = 744 h = 44640 m = 2378400 s		-- 1 d = 24 h = 1440 m = 86400 s		-- 1 h = 60 m = 3600 s		-- 1 m = 60 s		local remain = self.unix - skyblock_epoch self.repr = {} repr.year = 1 + math.floor(remain / 32140800) remain = remain - (repr.year - 1) * 32140800 repr.month = math.floor(remain / 2678400) remain = remain - repr.month * 2678400 repr.date = math.floor(remain / 86400) remain = remain - repr.date * 86400 repr.hour = math.floor(remain / 3600) remain = remain - repr.hour * 3600 repr.minute = math.floor(remain / 60) remain = remain - repr.minute * 60 repr.second = remain end -- Create and invoke class local Class = table.makeClass(constructor, methods) return Class(settings) end

return skydate