Module:BassaridianCalendar: Difference between revisions
From MicrasWiki
Jump to navigationJump to search
NewZimiaGov (talk | contribs) No edit summary Tag: Manual revert |
NewZimiaGov (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
function p.getCurrentDate() | function p.getCurrentDate() | ||
-- Get | -- Constants for Bassaridian Calendar | ||
local yearDay = tonumber(os.date(" | local yearStart = 237 -- August 25th is Day 237 in Gregorian year | ||
local calendarDays = 183 -- Total days in Bassaridian year | |||
local monthLength = 61 -- Each Bassaridian month has 61 days | |||
-- Adjust for Time Zone (if needed) | |||
local hourOffset = 0 -- Change to your local time offset (e.g., -6 for UTC-6) | |||
local adjustedTime = os.time() + (hourOffset * 3600) | |||
-- Get adjusted year day and Gregorian details | |||
local yearDay = tonumber(os.date("!*t", adjustedTime).yday) | |||
local isLeapYear = (tonumber(os.date("%Y")) % 4 == 0 and (tonumber(os.date("%Y")) % 100 ~= 0 or tonumber(os.date("%Y")) % 400 == 0)) | local isLeapYear = (tonumber(os.date("%Y")) % 4 == 0 and (tonumber(os.date("%Y")) % 100 ~= 0 or tonumber(os.date("%Y")) % 400 == 0)) | ||
local totalDays = isLeapYear and 366 or 365 -- Total days in the Gregorian year | local totalDays = isLeapYear and 366 or 365 -- Total days in the Gregorian year | ||
-- Adjust for Bassaridian calendar | -- Adjust for Bassaridian calendar | ||
local adjustedDay = yearDay - yearStart | local adjustedDay = yearDay - yearStart | ||
if adjustedDay < 0 then | if adjustedDay < 0 then | ||
adjustedDay = adjustedDay + totalDays -- | adjustedDay = adjustedDay + totalDays -- Wrap to previous year | ||
end | end | ||
local bassaridianDay = (adjustedDay % calendarDays) + 1 | local bassaridianDay = (adjustedDay % calendarDays) + 1 | ||
-- Determine month, day | -- Determine month, day, and zodiac sign | ||
local bassaridianMonth, bassaridianMonthDay, zodiacSign | local bassaridianMonth, bassaridianMonthDay, zodiacSign | ||
if bassaridianDay <= 61 then | if bassaridianDay <= 61 then | ||
Line 53: | Line 57: | ||
end | end | ||
-- Event lookup table | -- Event lookup table | ||
local events = { | local events = { | ||
["Atosiel,6"] = "Bayram al-Nur (Festival of Light) in [https://micras.org/mwiki/List_of_cities_in_Bassaridia_Vaeringheim#Vaeringheim Vaeringheim]", | ["Atosiel,6"] = "Bayram al-Nur (Festival of Light) in [https://micras.org/mwiki/List_of_cities_in_Bassaridia_Vaeringheim#Vaeringheim Vaeringheim]", | ||
-- Add more events as needed | |||
} | } | ||
-- Find | -- Find event for the current date | ||
local eventKey = bassaridianMonth .. "," .. bassaridianMonthDay | local eventKey = bassaridianMonth .. "," .. bassaridianMonthDay | ||
local event = events[eventKey] or "No significant events today." | local event = events[eventKey] or "No significant events today." | ||
-- Return | -- Return formatted date and event | ||
return | return bassaridianMonthDay .. ", " .. bassaridianMonth .. " (" .. zodiacSign .. "), 50 PSSC – " .. event | ||
end | |||
function p.testServerTime() | |||
return os.date("%Y-%m-%d %H:%M:%S %Z") | |||
end | end | ||
return p | return p |
Revision as of 00:11, 11 December 2024
Documentation for this module may be created at Module:BassaridianCalendar/doc
local p = {} function p.getCurrentDate() -- Constants for Bassaridian Calendar local yearStart = 237 -- August 25th is Day 237 in Gregorian year local calendarDays = 183 -- Total days in Bassaridian year local monthLength = 61 -- Each Bassaridian month has 61 days -- Adjust for Time Zone (if needed) local hourOffset = 0 -- Change to your local time offset (e.g., -6 for UTC-6) local adjustedTime = os.time() + (hourOffset * 3600) -- Get adjusted year day and Gregorian details local yearDay = tonumber(os.date("!*t", adjustedTime).yday) local isLeapYear = (tonumber(os.date("%Y")) % 4 == 0 and (tonumber(os.date("%Y")) % 100 ~= 0 or tonumber(os.date("%Y")) % 400 == 0)) local totalDays = isLeapYear and 366 or 365 -- Total days in the Gregorian year -- Adjust for Bassaridian calendar local adjustedDay = yearDay - yearStart if adjustedDay < 0 then adjustedDay = adjustedDay + totalDays -- Wrap to previous year end local bassaridianDay = (adjustedDay % calendarDays) + 1 -- Determine month, day, and zodiac sign local bassaridianMonth, bassaridianMonthDay, zodiacSign if bassaridianDay <= 61 then bassaridianMonth = "Atosiel" bassaridianMonthDay = bassaridianDay if bassaridianMonthDay <= 20 then zodiacSign = "Atosien" elseif bassaridianMonthDay <= 40 then zodiacSign = "Eosena" else zodiacSign = "Micrasha" end elseif bassaridianDay <= 121 then -- Month 2: Thalassiel bassaridianMonth = "Thalassiel" bassaridianMonthDay = bassaridianDay - 61 if bassaridianMonthDay <= 20 then zodiacSign = "Chrysen" elseif bassaridianMonthDay <= 40 then zodiacSign = "Thalassian" else zodiacSign = "Nephelia" end else -- Month 3: Opsitheiel bassaridianMonth = "Opsitheiel" bassaridianMonthDay = bassaridianDay - 121 if bassaridianMonthDay <= 20 then zodiacSign = "Opsithia" elseif bassaridianMonthDay <= 40 then zodiacSign = "Stygian" else zodiacSign = "Faunian" end end -- Event lookup table local events = { ["Atosiel,6"] = "Bayram al-Nur (Festival of Light) in [https://micras.org/mwiki/List_of_cities_in_Bassaridia_Vaeringheim#Vaeringheim Vaeringheim]", -- Add more events as needed } -- Find event for the current date local eventKey = bassaridianMonth .. "," .. bassaridianMonthDay local event = events[eventKey] or "No significant events today." -- Return formatted date and event return bassaridianMonthDay .. ", " .. bassaridianMonth .. " (" .. zodiacSign .. "), 50 PSSC – " .. event end function p.testServerTime() return os.date("%Y-%m-%d %H:%M:%S %Z") end return p