Module:HypixelServerTime

-- Returns a number: The offset of hypixel server time to UTC. -- "Daylight Saving Time (DST) in Canada starts on the 2nd Sunday in March and ends on the 1st Sunday in November." -- https://www.timeanddate.com/time/change/canada

local lang = mw.language.getContentLanguage

function main -- finding second sunday of march (SSOM) local dayofweekofmarch1 = tonumber(lang:formatDate('w', 'March 1')) -- 0: Sunday, 6: Saturday local ssomDate = (dayofweekofmarch1 == 0) and 8 or (15 - dayofweekofmarch1) -- finding first sunday of november (FSON) local dayofweekofnovember1 = tonumber(lang:formatDate('w', 'November 1')) -- 0: Sunday, 6: Saturday local fsonDate = (dayofweekofnovember1 == 0) and 1 or (8 - dayofweekofnovember1) mw.log(ssomDate, fsonDate) -- calculate current offset local currentTimestamp = lang:formatDate('U', '-5 hours') local ssomTimestamp = lang:formatDate('U', 'March ' .. ssomDate .. ' 02:00 -5 hours') local fsonTimestamp = lang:formatDate('U', 'November ' .. fsonDate .. ' 01:00 -5 hours') if currentTimestamp >= ssomTimestamp and currentTimestamp < fsonTimestamp then return -4 else return -5 end end

-- debug use -- return { -- 	main = main -- }

-- actual use return main