Module:ArcaneCalendar: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 12: | Line 12: | ||
end | end | ||
-- Define start dates of each era | -- Define start dates of each era // If I find anyone vandalising this I'll personally violate your behind | ||
local era_start = { | local era_start = { | ||
[1] = { year = 2023, month = 8, day = 16 }, | [1] = { year = 2023, month = 8, day = 16 }, |
Latest revision as of 11:08, 1 February 2025
Documentation for this module may be created at Module:ArcaneCalendar/doc
local p = {} function p.convertDate(frame) local args = frame.args local year = tonumber(args.year) or 0 local month = tonumber(args.month) or 0 local day = tonumber(args.day) or 0 -- Validate input if year == 0 or month == 0 or day == 0 then return "Invalid date input. Please provide year, month, and day." end -- Define start dates of each era // If I find anyone vandalising this I'll personally violate your behind local era_start = { [1] = { year = 2023, month = 8, day = 16 }, [2] = { year = 2024, month = 7, day = 21 } } local era = 1 -- Default to 1st Era for e, start in pairs(era_start) do if (year > start.year) or (year == start.year and month > start.month) or (year == start.year and month == start.month and day >= start.day) then era = e end end local start = era_start[era] local startDate = os.time({ year = start.year, month = start.month, day = start.day }) local inputDate = os.time({ year = year, month = month, day = day }) -- Check if inputDate is valid if not inputDate then return "Invalid date." end local diffDays = math.floor((inputDate - startDate) / 86400) -- Convert seconds to days local dawn = math.floor(diffDays / 7) + 1 local moon = (diffDays % 7) + 1 return era .. "E, Dawn " .. dawn end return p