Module:BassaridianCalendar

From MicrasWiki
Revision as of 03:26, 11 December 2024 by NewZimiaGov (talk | contribs)
Jump to navigationJump to search

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
    local daysPerYear = 183

    -- Current date
    local currentDate = os.time()
    local totalDaysElapsed = math.floor((currentDate - startDate) / secondsInDay)
    local yearFraction = totalDaysElapsed / daysPerYear
    local psscYear = math.floor(yearFraction)
    local dayOfYear = math.floor((yearFraction - psscYear) * daysPerYear) + 1

    -- Determine month, day, zodiac
    local month, dayInMonth, zodiac
    local zodiacs = {
        Atosiel = {"Atosien", "Eosena", "Micrasha", "Pyreska", "Indomin"},
        Thalassiel = {"Chrysen", "Thalassian", "Nephelia", "Glinaeus", "Noctien"},
        Opsitheiel = {"Opsithia", "Stygian", "Faunian", "Silenian", "Catosien"}
    }

    if dayOfYear <= 61 then
        month = "Atosiel"
        dayInMonth = dayOfYear
    elseif dayOfYear <= 122 then
        month = "Thalassiel"
        dayInMonth = dayOfYear - 61
    else
        month = "Opsitheiel"
        dayInMonth = dayOfYear - 122
    end

    local zodiacIndex = math.ceil(dayInMonth / 12.2)
    zodiac = zodiacs[month][zodiacIndex]

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

    -- Generate proverb and event
    local eventKey = month .. "," .. dayInMonth
    local event = events[eventKey] or "No significant events today."
    local proverb = "Proverb of " .. zodiac .. ": Seek balance and purpose."

    -- Return formatted date
    return dayOfYear .. ", " .. month .. " ([[Reformed_Stripping_Path#Overview_of_the_Bassaridian_Zodiac|" .. zodiac .. "]]), " .. psscYear .. " PSSC – " .. event .. " – " .. proverb
end

return p