Module:BassaridianCalendar: Difference between revisions
From MicrasWiki
Jump to navigationJump to search
NewZimiaGov (talk | contribs) Created page with "local p = {} function p.getCurrentDate() -- Get the current date local yearDay = tonumber(os.date("%j")) -- Day of the year (1-365/366) local month = tonumber(os.date("%m")) -- Current month (1-12) local day = tonumber(os.date("%d")) -- Day of the current month (1-31) local isLeapYear = (tonumber(os.date("%Y")) % 4 == 0 and (tonumber(os.date("%Y")) % 100 ~= 0 or tonumber(os.date("%Y")) % 400 == 0)) local totalDays = isLeapYear and 366 or 365 -- D..." |
NewZimiaGov (talk | contribs) No edit summary |
||
| Line 4: | Line 4: | ||
-- Get the current date | -- Get the current date | ||
local yearDay = tonumber(os.date("%j")) -- Day of the year (1-365/366) | local yearDay = tonumber(os.date("%j")) -- Day of the year (1-365/366) | ||
local isLeapYear = (tonumber(os.date("%Y")) % 4 == 0 and (tonumber(os.date("%Y")) % 100 ~= 0 or tonumber(os.date("%Y")) % 400 == 0)) | local isLeapYear = (tonumber(os.date("%Y")) % 4 == 0 and (tonumber(os.date("%Y")) % 100 ~= 0 or tonumber(os.date("%Y")) % 400 == 0)) | ||
local totalDays = isLeapYear and 366 or 365 -- Days in the year | local totalDays = isLeapYear and 366 or 365 -- Days in the Gregorian year | ||
-- Bassaridian calendar constants | -- Bassaridian calendar constants | ||
local yearStart = 237 -- August 25th is the | local yearStart = 237 -- August 25th is Day 237 in 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 month has 61 days | local monthLength = 61 -- Each month has 61 days | ||
-- Calculate current Bassaridian day of the year | -- Calculate current Bassaridian day of the year | ||
local | local adjustedDay = yearDay - yearStart | ||
local bassaridianDay = | if adjustedDay < 0 then | ||
adjustedDay = adjustedDay + totalDays -- Adjust for previous year if needed | |||
end | |||
local bassaridianDay = (adjustedDay % calendarDays) + 1 | |||
-- Determine the month and day | -- Determine the month and day within the month | ||
local bassaridianMonth, bassaridianMonthDay | local bassaridianMonth, bassaridianMonthDay | ||
if bassaridianDay <= monthLength then | if bassaridianDay <= monthLength then | ||
Revision as of 02:45, 10 December 2024
Documentation for this module may be created at Module:BassaridianCalendar/doc
local p = {}
function p.getCurrentDate()
-- Get the current date
local yearDay = tonumber(os.date("%j")) -- Day of the year (1-365/366)
local isLeapYear = (tonumber(os.date("%Y")) % 4 == 0 and (tonumber(os.date("%Y")) % 100 ~= 0 or tonumber(os.date("%Y")) % 400 == 0))
local totalDays = isLeapYear and 366 or 365 -- Days in the Gregorian year
-- Bassaridian calendar constants
local yearStart = 237 -- August 25th is Day 237 in the Gregorian year
local calendarDays = 183 -- Total days in the Bassaridian year
local monthLength = 61 -- Each month has 61 days
-- Calculate current Bassaridian day of the year
local adjustedDay = yearDay - yearStart
if adjustedDay < 0 then
adjustedDay = adjustedDay + totalDays -- Adjust for previous year if needed
end
local bassaridianDay = (adjustedDay % calendarDays) + 1
-- Determine the month and day within the month
local bassaridianMonth, bassaridianMonthDay
if bassaridianDay <= monthLength then
bassaridianMonth = "Month 1"
bassaridianMonthDay = bassaridianDay
elseif bassaridianDay <= 2 * monthLength then
bassaridianMonth = "Month 2"
bassaridianMonthDay = bassaridianDay - monthLength
else
bassaridianMonth = "Month 3"
bassaridianMonthDay = bassaridianDay - 2 * monthLength
end
-- Event lookup table
local events = {
["Month 1,6"] = "Bayram al-Nur (Festival of Light) in Vaeringheim",
["Month 1,18"] = "Chag Or Hadash (Festival of New Light) in Luminaria",
["Month 1,30"] = "Symposion Eirinis (Symposium of Harmony) in Serena",
["Month 1,43"] = "Alev Günü (Day of Flame) in Pyralis",
["Month 1,55"] = "Tikkun Tzel (Repair of Shadows) in Symphonara",
["Month 2,67"] = "Panegyris Chrysou (Golden Gathering) in Aurelia",
["Month 2,80"] = "Mehtap Dalgası (Moonlit Tide) in Vaeringheim",
["Month 2,92"] = "Oneiro Foteino (Dream of Illumination) in Somniumpolis",
["Month 2,105"] = "Erev Galgal (Eve of Cycles) in Nexa",
["Month 2,115"] = "Leilat al-Kamar (Night of the Moon) in Lunalis Sancta",
["Month 3,128"] = "Chag Tvuah (Festival of Harvest) in Sylvapolis",
["Month 3,140"] = "Anagenesis Eirmos (Procession of Rebirth) in Acheron",
["Month 3,150"] = "Panagia Therizis (Holy Day of the Reaper) in Sylvapolis",
["Month 3,165"] = "Karnavali Thysias (Carnival of Celebration) in Erythros",
["Month 3,175"] = "Sefar Yashar (Straight Path Celebration) in Catonis Atrium",
}
-- Find the event for the current date
local eventKey = bassaridianMonth .. "," .. bassaridianMonthDay
local event = events[eventKey] or "No significant events today."
-- Return the full date and event
return bassaridianMonth .. ", Day " .. bassaridianMonthDay .. " – " .. event
end
return p