Module:BassaridianCalendar: Difference between revisions

From MicrasWiki
Jump to navigationJump to search
NewZimiaGov (talk | contribs)
No edit summary
NewZimiaGov (talk | contribs)
No edit summary
Line 2: Line 2:


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


     -- Bassaridian calendar constants
     -- Bassaridian calendar constants
     local yearStart = 237 -- August 25th is Day 237 in the Gregorian calendar
     local yearStart = 237 -- August 25th is Day 237 in the Gregorian calendar
     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 the 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 -- Adjust for wraparound to previous year
         adjustedDay = adjustedDay + totalDays -- Adjust for wraparound to the previous year
     end
     end
     local bassaridianDay = (adjustedDay % calendarDays) + 1
     local bassaridianDay = (adjustedDay % calendarDays) + 1


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


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


     -- Return the formatted date
     -- Return the formatted date

Revision as of 02:04, 11 December 2024

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

local p = {}

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

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

    -- Adjust for Bassaridian calendar
    local adjustedDay = yearDay - yearStart
    if adjustedDay < 0 then
        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
    local bassaridianMonth, zodiacSign
    if bassaridianDay <= 61 then -- Month 1: Atosiel
        bassaridianMonth = "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 2: Thalassiel
        bassaridianMonth = "Thalassiel"
        local dayInMonth = bassaridianDay - 61
        if dayInMonth <= 12 then
            zodiacSign = "Chrysen"
        elseif dayInMonth <= 24 then
            zodiacSign = "Thalassian"
        elseif dayInMonth <= 36 then
            zodiacSign = "Nephelia"
        elseif dayInMonth <= 48 then
            zodiacSign = "Glinaeus"
        else
            zodiacSign = "Noctien"
        end
    else -- Month 3: Opsitheiel
        bassaridianMonth = "Opsitheiel"
        local dayInMonth = bassaridianDay - 121
        if dayInMonth <= 12 then
            zodiacSign = "Opsithia"
        elseif dayInMonth <= 24 then
            zodiacSign = "Stygian"
        elseif dayInMonth <= 36 then
            zodiacSign = "Faunian"
        elseif dayInMonth <= 48 then
            zodiacSign = "Silenian"
        else
            zodiacSign = "Catosien"
        end
    end

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

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

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

return p