Module:Sandbox/MonkeysHK/2

require('Module:LoadLib')(_G)

-- Set exports local skydate = {}

function skydate:create(settings) local methods = {} local skyblock_epoch = 1560275700 function methods:constructor(settings) if not settings then self.unix = os.time(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(str) -- prepares self.unix end function methods:_unixConvert -- 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 = {} self.repr.year = 1 + math.floor(remain / 32140800) remain = remain - (repr.year - 1) * 32140800 self.repr.month = math.floor(remain / 2678400) remain = remain - repr.month * 2678400 self.repr.date = math.floor(remain / 86400) remain = remain - repr.date * 86400 self.repr.hour = math.floor(remain / 3600) remain = remain - repr.hour * 3600 self.repr.minute = math.floor(remain / 60) remain = remain - repr.minute * 60 self.repr.second = remain end -- Create and invoke class local Class = table.makeClass(methods) return Class(settings) end

return skydate