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 the current Gregorian date and time in CDT (adjusting for UTC offset)
     -- Constants
     local utcTime = os.time(os.date("!*t"))
     local startDate = os.time({year = 1999, month = 8, day = 6}) -- August 6, 1999
    local cdtTime = utcTime - (6 * 3600) -- CDT is UTC-6
     local secondsInDay = 24 * 60 * 60 -- Number of seconds in a day
     local yearDay = tonumber(os.date("%j", cdtTime)) -- Day of the year (1-365/366)
     local daysPerYear = 183
     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 yearStartDay = 1
     local totalDays = isLeapYear and 366 or 365 -- Total days in the Gregorian year
    local monthLength = 61
     local psscStartYear = 50


     -- Bassaridian calendar constants
     -- Current date
     local yearStart = 237 -- August 25th is Day 237 in the Gregorian calendar
     local currentDate = os.time()
     local calendarDays = 183 -- Total days in the Bassaridian year
     local totalDaysElapsed = math.floor((currentDate - startDate) / secondsInDay)
    local monthLength = 61 -- Each Bassaridian month has 61 days


     -- Adjust for Bassaridian calendar
     -- Calculate PSSC year and day
     local adjustedDay = yearDay - yearStart
     local psscYear = math.floor(totalDaysElapsed / daysPerYear) + psscStartYear
    if adjustedDay < 0 then
     local dayOfYear = (totalDaysElapsed % daysPerYear) + 1
        adjustedDay = adjustedDay + totalDays -- Adjust for wraparound to the previous year
    end
     local bassaridianDay = (adjustedDay % calendarDays) + 1


     -- Determine month, day within the month, and zodiac sign
     -- Determine month and day within the month
     local bassaridianMonth, zodiacSign
     local month, dayInMonth, zodiac
     if bassaridianDay <= 61 then -- Month 1: Atosiel
     if dayOfYear <= monthLength then
         bassaridianMonth = "Atosiel"
         month = "Atosiel"
         if bassaridianDay <= 12 then
        dayInMonth = dayOfYear
             zodiacSign = "Atosien"
         if dayInMonth <= 12 then
         elseif bassaridianDay <= 24 then
             zodiac = "Atosien"
             zodiacSign = "Eosena"
         elseif dayInMonth <= 24 then
         elseif bassaridianDay <= 36 then
             zodiac = "Eosena"
             zodiacSign = "Micrasha"
         elseif dayInMonth <= 36 then
         elseif bassaridianDay <= 48 then
             zodiac = "Micrasha"
             zodiacSign = "Pyreska"
         elseif dayInMonth <= 48 then
             zodiac = "Pyreska"
         else
         else
             zodiacSign = "Indomin"
             zodiac = "Indomin"
         end
         end
     elseif bassaridianDay <= 121 then -- Month 2: Thalassiel
     elseif dayOfYear <= 2 * monthLength then
         bassaridianMonth = "Thalassiel"
         month = "Thalassiel"
         local dayInMonth = bassaridianDay - 61
         dayInMonth = dayOfYear - monthLength
         if dayInMonth <= 12 then
         if dayInMonth <= 12 then
             zodiacSign = "Chrysen"
             zodiac = "Chrysen"
         elseif dayInMonth <= 24 then
         elseif dayInMonth <= 24 then
             zodiacSign = "Thalassian"
             zodiac = "Thalassian"
         elseif dayInMonth <= 36 then
         elseif dayInMonth <= 36 then
             zodiacSign = "Nephelia"
             zodiac = "Nephelia"
         elseif dayInMonth <= 48 then
         elseif dayInMonth <= 48 then
             zodiacSign = "Glinaeus"
             zodiac = "Glinaeus"
         else
         else
             zodiacSign = "Noctien"
             zodiac = "Noctien"
         end
         end
     else -- Month 3: Opsitheiel
     else
         bassaridianMonth = "Opsitheiel"
         month = "Opsitheiel"
         local dayInMonth = bassaridianDay - 121
         dayInMonth = dayOfYear - 2 * monthLength
         if dayInMonth <= 12 then
         if dayInMonth <= 12 then
             zodiacSign = "Opsithia"
             zodiac = "Opsithia"
         elseif dayInMonth <= 24 then
         elseif dayInMonth <= 24 then
             zodiacSign = "Stygian"
             zodiac = "Stygian"
         elseif dayInMonth <= 36 then
         elseif dayInMonth <= 36 then
             zodiacSign = "Faunian"
             zodiac = "Faunian"
         elseif dayInMonth <= 48 then
         elseif dayInMonth <= 48 then
             zodiacSign = "Silenian"
             zodiac = "Silenian"
         else
         else
             zodiacSign = "Catosien"
             zodiac = "Catosien"
         end
         end
     end
     end
Line 68: Line 66:
     -- 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)",
         ["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)",
         ["30,Atosiel"] = "Symposion Eirinis (Symposium of Harmony) in [[List of cities in Bassaridia Vaeringheim#Serena|Serena]]",
         ["Atosiel,30"] = "Symposion Eirinis (Symposium of Harmony)",
         ["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)",
         ["55,Atosiel"] = "Tikkun Tzel (Repair of Shadows) in [[List of cities in Bassaridia Vaeringheim#Symphonara|Symphonara]]",
         ["Atosiel,55"] = "Tikkun Tzel (Repair of Shadows)",
         ["67,Thalassiel"] = "Panegyris Chrysou (Golden Gathering) in [[List of cities in Bassaridia Vaeringheim#Aurelia|Aurelia]]",
         ["Thalassiel,67"] = "Panegyris Chrysou (Golden Gathering)",
         ["80,Thalassiel"] = "Mehtap Dalgası (Moonlit Tide) in [[List of cities in Bassaridia Vaeringheim#Vaeringheim|Vaeringheim]]",
         ["Thalassiel,80"] = "Mehtap Dalgası (Moonlit Tide)",
         ["92,Thalassiel"] = "Oneiro Foteino (Dream of Illumination) in [[List of cities in Bassaridia Vaeringheim#Somniumpolis|Somniumpolis]]",
         ["Thalassiel,92"] = "Oneiro Foteino (Dream of Illumination)",
         ["105,Thalassiel"] = "Erev Galgal (Eve of Cycles) in [[List of cities in Bassaridia Vaeringheim#Nexa|Nexa]]",
         ["Thalassiel,105"] = "Erev Galgal (Eve of Cycles)",
         ["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)",
         ["128,Opsitheiel"] = "Chag Tvuah (Festival of Harvest) in [[List of cities in Bassaridia Vaeringheim#Sylvapolis|Sylvapolis]]",
         ["Opsitheiel,128"] = "Chag Tvuah (Festival of Harvest)",
         ["140,Opsitheiel"] = "Anagenesis Eirmos (Procession of Rebirth) in [[List of cities in Bassaridia Vaeringheim#Acheron|Acheron]]",
         ["Opsitheiel,140"] = "Anagenesis Eirmos (Procession of Rebirth)",
         ["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)",
         ["165,Opsitheiel"] = "Karnavali Thysias (Carnival of Celebration) in [[List of cities in Bassaridia Vaeringheim#Erythros|Erythros]]",
         ["Opsitheiel,165"] = "Karnavali Thysias (Carnival of Celebration)",
         ["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)"
     }
     }


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


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


return p
return p

Revision as of 02:37, 11 December 2024

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

local p = {}

function p.getCurrentDate()
    -- Constants
    local startDate = os.time({year = 1999, month = 8, day = 6}) -- August 6, 1999
    local secondsInDay = 24 * 60 * 60 -- Number of seconds in a day
    local daysPerYear = 183
    local yearStartDay = 1
    local monthLength = 61
    local psscStartYear = 50

    -- Current date
    local currentDate = os.time()
    local totalDaysElapsed = math.floor((currentDate - startDate) / secondsInDay)

    -- Calculate PSSC year and day
    local psscYear = math.floor(totalDaysElapsed / daysPerYear) + psscStartYear
    local dayOfYear = (totalDaysElapsed % daysPerYear) + 1

    -- Determine month and day within the month
    local month, dayInMonth, zodiac
    if dayOfYear <= monthLength then
        month = "Atosiel"
        dayInMonth = dayOfYear
        if dayInMonth <= 12 then
            zodiac = "Atosien"
        elseif dayInMonth <= 24 then
            zodiac = "Eosena"
        elseif dayInMonth <= 36 then
            zodiac = "Micrasha"
        elseif dayInMonth <= 48 then
            zodiac = "Pyreska"
        else
            zodiac = "Indomin"
        end
    elseif dayOfYear <= 2 * monthLength then
        month = "Thalassiel"
        dayInMonth = dayOfYear - monthLength
        if dayInMonth <= 12 then
            zodiac = "Chrysen"
        elseif dayInMonth <= 24 then
            zodiac = "Thalassian"
        elseif dayInMonth <= 36 then
            zodiac = "Nephelia"
        elseif dayInMonth <= 48 then
            zodiac = "Glinaeus"
        else
            zodiac = "Noctien"
        end
    else
        month = "Opsitheiel"
        dayInMonth = dayOfYear - 2 * monthLength
        if dayInMonth <= 12 then
            zodiac = "Opsithia"
        elseif dayInMonth <= 24 then
            zodiac = "Stygian"
        elseif dayInMonth <= 36 then
            zodiac = "Faunian"
        elseif dayInMonth <= 48 then
            zodiac = "Silenian"
        else
            zodiac = "Catosien"
        end
    end

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

    -- Determine the event for the current day
    local eventKey = month .. "," .. dayInMonth
    local event = events[eventKey] or "No significant events today."

    -- Return the formatted date
    return dayOfYear .. ", " .. month .. " (" .. zodiac .. "), " .. psscYear .. " PSSC – " .. event
end

return p