Module:TarsicanSaros
From MicrasWiki
Documentation for this module may be created at Module:TarsicanSaros/doc
local p = {}
local calendar = require("Module:BassaridianCalendar") -- Make sure this matches your module name
-- Constants
local synodicPeriod = 24.8
local micrasYearLength = 183
-- Zodiac definitions
local zodiacSigns = {
{ name = "Atosien", start = 1, stop = 12 },
{ name = "Eosena", start = 13, stop = 24 },
{ name = "Micrasha", start = 25, stop = 36 },
{ name = "Pyreska", start = 37, stop = 48 },
{ name = "Indomin", start = 49, stop = 61 },
{ name = "Chrysen", start = 62, stop = 73 },
{ name = "Thalassian", start = 74, stop = 85 },
{ name = "Nephelia", start = 86, stop = 97 },
{ name = "Glinaeus", start = 98, stop = 109 },
{ name = "Noctien", start = 110, stop = 122 },
{ name = "Opsithia", start = 123, stop = 133 },
{ name = "Stygian", start = 134, stop = 145 },
{ name = "Faunian", start = 146, stop = 157 },
{ name = "Silenian", start = 158, stop = 169 },
{ name = "Catosien", start = 170, stop = 183 }
}
-- Get month based on day
local function getMonth(day)
if day <= 61 then return "Atosiel"
elseif day <= 122 then return "Thalassiel"
else return "Opsitheiel"
end
end
-- Get zodiac based on day
local function getZodiac(day)
for _, z in ipairs(zodiacSigns) do
if day >= z.start and day <= z.stop then
return z.name
end
end
return "Unknown"
end
-- Generate a random eclipse subtype
local function getEclipseSubtype(eclipseType)
math.randomseed(os.time())
if eclipseType == "Solar" then
local types = { "Total Solar", "Annular Solar", "Partial Solar" }
return types[math.random(#types)]
else
local types = { "Total Lunar", "Penumbral Lunar", "Partial Lunar" }
return types[math.random(#types)]
end
end
-- MAIN FUNCTION
function p.sarosTable(frame)
local output = {}
-- Get date string: e.g. "18, Atosiel (Eosena), 51 PSSC – ..."
local dateString = calendar.getCurrentDate()
local psscYear = tonumber(string.match(dateString, "(%d+)%s+PSSC"))
local events = calendar.events or {}
table.insert(output, string.format("== Tarsican Eclipse Schedule – Year %d PSSC ==\n", psscYear))
table.insert(output, '{| class="wikitable" style="width:100%; text-align:center;"')
table.insert(output, '|-\n! Eclipse # !! Day !! Month !! Zodiac Sign !! Eclipse Type !! Nearby Ritual or Holiday')
local eclipseDay = 18
local isSolar = true
for i = 1, 10 do
if eclipseDay > micrasYearLength then break end
local eclipseType = isSolar and "Solar" or "Lunar"
local subtype = getEclipseSubtype(eclipseType)
local month = getMonth(eclipseDay)
local zodiac = getZodiac(eclipseDay)
-- Look for nearby events ±1 day
local nearbyEvent = "—"
for offset = -1, 1 do
local checkDay = eclipseDay + offset
if checkDay >= 1 and checkDay <= micrasYearLength then
local checkMonth = getMonth(checkDay)
local dayInMonth = checkDay
if checkMonth == "Thalassiel" then
dayInMonth = checkDay - 61
elseif checkMonth == "Opsitheiel" then
dayInMonth = checkDay - 122
end
local key = checkMonth .. "," .. dayInMonth
if events[key] then
nearbyEvent = events[key]
break
end
end
end
table.insert(output, string.format('|-\n| %d || %d || %s || %s || %s || %s',
i, eclipseDay, month, zodiac, subtype, nearbyEvent
))
eclipseDay = math.floor(eclipseDay + synodicPeriod + ((-1)^i) * 2.3)
isSolar = not isSolar
end
table.insert(output, '|}')
return table.concat(output, "\n")
end
return p