Module:BassaridianCalendar: Difference between revisions

From MicrasWiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 2: Line 2:


function p.getCurrentDate()
function p.getCurrentDate()
     -- Get the current Gregorian date and time in CDT (adjusting for UTC offset)
     -- Get the current Gregorian date
     local utcTime = os.time(os.date("!*t"))
     local currentDate = os.date("*t")
     local cdtTime = utcTime - (6 * 3600) -- CDT is UTC-6
     local gregorianDay = currentDate.yday -- Day of the year (1-365/366)
    local yearDay = tonumber(os.date("%j", cdtTime)) -- Day of the year (1-365/366)
     local isLeapYear = (currentDate.year % 4 == 0 and (currentDate.year % 100 ~= 0 or currentDate.year % 400 == 0))
     local isLeapYear = (tonumber(os.date("%Y", cdtTime)) % 4 == 0 and (tonumber(os.date("%Y", cdtTime)) % 100 ~= 0 or tonumber(os.date("%Y", cdtTime)) % 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


     -- Bassaridian calendar constants
     -- PSSC and Bassaridian calendar constants
     local yearStart = 237 -- August 25th is Day 237 in the Gregorian calendar
     local bassaridianStart = 237 -- August 25th is the 237th day of the Gregorian year
     local calendarDays = 183 -- Total days in the Bassaridian year
     local calendarDays = 183 -- Total days in the Bassaridian year
    local monthLength = 61 -- Each Bassaridian month has 61 days


     -- Adjust for Bassaridian calendar
     -- Calculate PSSC year
     local adjustedDay = yearDay - yearStart
    local psscYear = currentDate.year - 1970 + (gregorianDay >= 60 and 1 or 0) -- PSSC year increments on March 1st
 
    -- Calculate Bassaridian day
     local adjustedDay = gregorianDay - bassaridianStart
     if adjustedDay < 0 then
     if adjustedDay < 0 then
         adjustedDay = adjustedDay + totalDays -- Adjust for wraparound to the previous year
         adjustedDay = adjustedDay + totalDays -- Wrap around for the previous year
     end
     end
     local bassaridianDay = (adjustedDay % calendarDays) + 1
     local bassaridianDay = (adjustedDay % calendarDays) + 1


     -- Determine month, day within the month, and zodiac sign
     -- Determine month and zodiac sign
     local bassaridianMonth, zodiacSign
     local month, zodiacSign
     if bassaridianDay <= 61 then -- Month 1: Atosiel
     if bassaridianDay <= 61 then
         bassaridianMonth = "Atosiel"
         month = "Atosiel"
         if bassaridianDay <= 12 then
         if bassaridianDay <= 12 then
             zodiacSign = "Atosien"
             zodiacSign = "Atosien"
Line 36: Line 37:
             zodiacSign = "Indomin"
             zodiacSign = "Indomin"
         end
         end
     elseif bassaridianDay <= 121 then -- Month 2: Thalassiel
     elseif bassaridianDay <= 121 then
         bassaridianMonth = "Thalassiel"
         month = "Thalassiel"
         local dayInMonth = bassaridianDay - 61
         if bassaridianDay <= 73 then
        if dayInMonth <= 12 then
             zodiacSign = "Chrysen"
             zodiacSign = "Chrysen"
         elseif dayInMonth <= 24 then
         elseif bassaridianDay <= 85 then
             zodiacSign = "Thalassian"
             zodiacSign = "Thalassian"
         elseif dayInMonth <= 36 then
         elseif bassaridianDay <= 97 then
             zodiacSign = "Nephelia"
             zodiacSign = "Nephelia"
         elseif dayInMonth <= 48 then
         elseif bassaridianDay <= 109 then
             zodiacSign = "Glinaeus"
             zodiacSign = "Glinaeus"
         else
         else
             zodiacSign = "Noctien"
             zodiacSign = "Noctien"
         end
         end
     else -- Month 3: Opsitheiel
     else
         bassaridianMonth = "Opsitheiel"
         month = "Opsitheiel"
         local dayInMonth = bassaridianDay - 121
         if bassaridianDay <= 133 then
        if dayInMonth <= 12 then
             zodiacSign = "Opsithia"
             zodiacSign = "Opsithia"
         elseif dayInMonth <= 24 then
         elseif bassaridianDay <= 145 then
             zodiacSign = "Stygian"
             zodiacSign = "Stygian"
         elseif dayInMonth <= 36 then
         elseif bassaridianDay <= 157 then
             zodiacSign = "Faunian"
             zodiacSign = "Faunian"
         elseif dayInMonth <= 48 then
         elseif bassaridianDay <= 169 then
             zodiacSign = "Silenian"
             zodiacSign = "Silenian"
         else
         else
Line 68: Line 67:
     -- Event lookup table
     -- Event lookup table
     local events = {
     local events = {
         ["6,Atosiel"] = "Bayram al-Nur (Festival of Light) in [[List of cities in Bassaridia Vaeringheim#Vaeringheim|Vaeringheim]]",
         ["Atosiel,6"] = "Bayram al-Nur (Festival of Light) in [[Vaeringheim]]",
         ["18,Atosiel"] = "Chag Or Hadash (Festival of New Light) in [[List of cities in Bassaridia Vaeringheim#Luminaria|Luminaria]]",
         ["Atosiel,18"] = "Chag Or Hadash (Festival of New Light) in [[Luminaria]]",
         ["30,Atosiel"] = "Symposion Eirinis (Symposium of Harmony) in [[List of cities in Bassaridia Vaeringheim#Serena|Serena]]",
         ["Atosiel,30"] = "Symposion Eirinis (Symposium of Harmony) in [[Serena]]",
         ["43,Atosiel"] = "Alev Günü (Day of Flame) in [[List of cities in Bassaridia Vaeringheim#Pyralis|Pyralis]]",
         ["Atosiel,43"] = "Alev Günü (Day of Flame) in [[Pyralis]]",
         ["55,Atosiel"] = "Tikkun Tzel (Repair of Shadows) in [[List of cities in Bassaridia Vaeringheim#Symphonara|Symphonara]]",
         ["Atosiel,55"] = "Tikkun Tzel (Repair of Shadows) in [[Symphonara]]",
         ["67,Thalassiel"] = "Panegyris Chrysou (Golden Gathering) in [[List of cities in Bassaridia Vaeringheim#Aurelia|Aurelia]]",
         ["Thalassiel,67"] = "Panegyris Chrysou (Golden Gathering) in [[Aurelia]]",
         ["80,Thalassiel"] = "Mehtap Dalgası (Moonlit Tide) in [[List of cities in Bassaridia Vaeringheim#Vaeringheim|Vaeringheim]]",
         ["Thalassiel,80"] = "Mehtap Dalgası (Moonlit Tide) in [[Vaeringheim]]",
         ["92,Thalassiel"] = "Oneiro Foteino (Dream of Illumination) in [[List of cities in Bassaridia Vaeringheim#Somniumpolis|Somniumpolis]]",
         ["Thalassiel,92"] = "Oneiro Foteino (Dream of Illumination) in [[Somniumpolis]]",
         ["105,Thalassiel"] = "Erev Galgal (Eve of Cycles) in [[List of cities in Bassaridia Vaeringheim#Nexa|Nexa]]",
         ["Thalassiel,105"] = "Erev Galgal (Eve of Cycles) in [[Nexa]]",
         ["115,Thalassiel"] = "Leilat al-Kamar (Night of the Moon) in [[List of cities in Bassaridia Vaeringheim#Lunalis Sancta|Lunalis Sancta]]",
         ["Thalassiel,115"] = "Leilat al-Kamar (Night of the Moon) in [[Lunalis Sancta]]",
         ["128,Opsitheiel"] = "Chag Tvuah (Festival of Harvest) in [[List of cities in Bassaridia Vaeringheim#Sylvapolis|Sylvapolis]]",
         ["Opsitheiel,128"] = "Chag Tvuah (Festival of Harvest) in [[Sylvapolis]]",
         ["140,Opsitheiel"] = "Anagenesis Eirmos (Procession of Rebirth) in [[List of cities in Bassaridia Vaeringheim#Acheron|Acheron]]",
         ["Opsitheiel,140"] = "Anagenesis Eirmos (Procession of Rebirth) in [[Acheron]]",
         ["150,Opsitheiel"] = "Panagia Therizis (Holy Day of the Reaper) in [[List of cities in Bassaridia Vaeringheim#Sylvapolis|Sylvapolis]]",
         ["Opsitheiel,150"] = "Panagia Therizis (Holy Day of the Reaper) in [[Sylvapolis]]",
         ["165,Opsitheiel"] = "Karnavali Thysias (Carnival of Celebration) in [[List of cities in Bassaridia Vaeringheim#Erythros|Erythros]]",
         ["Opsitheiel,165"] = "Karnavali Thysias (Carnival of Celebration) in [[Erythros]]",
         ["175,Opsitheiel"] = "Sefar Yashar (Straight Path Celebration) in [[List of cities in Bassaridia Vaeringheim#Catonis Atrium|Catonis Atrium]]",
         ["Opsitheiel,175"] = "Sefar Yashar (Straight Path Celebration) in [[Catonis Atrium]]",
     }
     }


     -- Find the event for the current date
     -- Find event for the current date
     local eventKey = bassaridianDay .. "," .. bassaridianMonth
     local eventKey = month .. "," .. bassaridianDay
     local event = events[eventKey] or "No significant events today."
     local event = events[eventKey] or "No significant events today."


     -- Return the formatted date
     -- Return formatted date
     return bassaridianDay .. ", " .. bassaridianMonth .. " (" .. zodiacSign .. "), 50 PSSC – " .. event
     return bassaridianDay .. ", " .. month .. " (" .. zodiacSign .. "), " .. psscYear .. " PSSC – " .. event
end
end


return p
return p

Revision as of 02:11, 11 December 2024

Documentation for this module may be created at Module:BassaridianCalendar/doc

local p = {}

function p.getCurrentDate()
    -- Get the current Gregorian date
    local currentDate = os.date("*t")
    local gregorianDay = currentDate.yday -- Day of the year (1-365/366)
    local isLeapYear = (currentDate.year % 4 == 0 and (currentDate.year % 100 ~= 0 or currentDate.year % 400 == 0))
    local totalDays = isLeapYear and 366 or 365 -- Total days in the Gregorian year

    -- PSSC and Bassaridian calendar constants
    local bassaridianStart = 237 -- August 25th is the 237th day of the Gregorian year
    local calendarDays = 183 -- Total days in the Bassaridian year

    -- Calculate PSSC year
    local psscYear = currentDate.year - 1970 + (gregorianDay >= 60 and 1 or 0) -- PSSC year increments on March 1st

    -- Calculate Bassaridian day
    local adjustedDay = gregorianDay - bassaridianStart
    if adjustedDay < 0 then
        adjustedDay = adjustedDay + totalDays -- Wrap around for the previous year
    end
    local bassaridianDay = (adjustedDay % calendarDays) + 1

    -- Determine month and zodiac sign
    local month, zodiacSign
    if bassaridianDay <= 61 then
        month = "Atosiel"
        if bassaridianDay <= 12 then
            zodiacSign = "Atosien"
        elseif bassaridianDay <= 24 then
            zodiacSign = "Eosena"
        elseif bassaridianDay <= 36 then
            zodiacSign = "Micrasha"
        elseif bassaridianDay <= 48 then
            zodiacSign = "Pyreska"
        else
            zodiacSign = "Indomin"
        end
    elseif bassaridianDay <= 121 then
        month = "Thalassiel"
        if bassaridianDay <= 73 then
            zodiacSign = "Chrysen"
        elseif bassaridianDay <= 85 then
            zodiacSign = "Thalassian"
        elseif bassaridianDay <= 97 then
            zodiacSign = "Nephelia"
        elseif bassaridianDay <= 109 then
            zodiacSign = "Glinaeus"
        else
            zodiacSign = "Noctien"
        end
    else
        month = "Opsitheiel"
        if bassaridianDay <= 133 then
            zodiacSign = "Opsithia"
        elseif bassaridianDay <= 145 then
            zodiacSign = "Stygian"
        elseif bassaridianDay <= 157 then
            zodiacSign = "Faunian"
        elseif bassaridianDay <= 169 then
            zodiacSign = "Silenian"
        else
            zodiacSign = "Catosien"
        end
    end

    -- Event lookup table
    local events = {
        ["Atosiel,6"] = "Bayram al-Nur (Festival of Light) in [[Vaeringheim]]",
        ["Atosiel,18"] = "Chag Or Hadash (Festival of New Light) in [[Luminaria]]",
        ["Atosiel,30"] = "Symposion Eirinis (Symposium of Harmony) in [[Serena]]",
        ["Atosiel,43"] = "Alev Günü (Day of Flame) in [[Pyralis]]",
        ["Atosiel,55"] = "Tikkun Tzel (Repair of Shadows) in [[Symphonara]]",
        ["Thalassiel,67"] = "Panegyris Chrysou (Golden Gathering) in [[Aurelia]]",
        ["Thalassiel,80"] = "Mehtap Dalgası (Moonlit Tide) in [[Vaeringheim]]",
        ["Thalassiel,92"] = "Oneiro Foteino (Dream of Illumination) in [[Somniumpolis]]",
        ["Thalassiel,105"] = "Erev Galgal (Eve of Cycles) in [[Nexa]]",
        ["Thalassiel,115"] = "Leilat al-Kamar (Night of the Moon) in [[Lunalis Sancta]]",
        ["Opsitheiel,128"] = "Chag Tvuah (Festival of Harvest) in [[Sylvapolis]]",
        ["Opsitheiel,140"] = "Anagenesis Eirmos (Procession of Rebirth) in [[Acheron]]",
        ["Opsitheiel,150"] = "Panagia Therizis (Holy Day of the Reaper) in [[Sylvapolis]]",
        ["Opsitheiel,165"] = "Karnavali Thysias (Carnival of Celebration) in [[Erythros]]",
        ["Opsitheiel,175"] = "Sefar Yashar (Straight Path Celebration) in [[Catonis Atrium]]",
    }

    -- Find event for the current date
    local eventKey = month .. "," .. bassaridianDay
    local event = events[eventKey] or "No significant events today."

    -- Return formatted date
    return bassaridianDay .. ", " .. month .. " (" .. zodiacSign .. "), " .. psscYear .. " PSSC – " .. event
end

return p