Module:Today/GA: Difference between revisions

From TSP Encyclopedia
Jump to navigation Jump to search
No edit summary
(maybe???)
Line 9: Line 9:
-- Function to convert Gregorian date to 10-month calendar date
-- Function to convert Gregorian date to 10-month calendar date
function M.convertTo10MonthCalendar(year, month, day)
function M.convertTo10MonthCalendar(year, month, day)
    mw.log("Year:", year)
    mw.log("Month:", month)
    mw.log("Day:", day)
year = tonumber(year)
year = tonumber(year)
     month = tonumber(month)
     month = tonumber(month)

Revision as of 19:46, 11 August 2023

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

------ IMPERIAL GALACTYAN CALENDAR ------

local M = {}

-- Define the number of months and days in each month
local numMonths = 10
local daysPerMonth = 59

-- Function to convert Gregorian date to 10-month calendar date
function M.convertTo10MonthCalendar(year, month, day)
    mw.log("Year:", year)
    mw.log("Month:", month)
    mw.log("Day:", day)
	
	year = tonumber(year)
    month = tonumber(month)
    day = tonumber(day)
    -- Perform calculations here to convert the date
    local totalDays = (year - 1) * 365 + math.floor((year - 1) / 4) + day
    local monthIndex = math.floor((totalDays - 1) / daysPerMonth) + 1
    local dayInMonth = (totalDays - 1) % daysPerMonth + 1
    
    return monthIndex, dayInMonth
end

-- Function to convert 10-month calendar date back to Gregorian date
function M.convertToGregorianCalendar(monthIndex, dayInMonth)
    monthIndex = tonumber(monthIndex)
    dayInMonth = tonumber(dayInMonth)
    -- Perform calculations here to convert the date
    local totalDays = (monthIndex - 1) * daysPerMonth + dayInMonth
    local year = math.floor(totalDays / 365) + 1
    local remainingDays = totalDays % 365
    
    local leapYear = (year % 4 == 0)
    if remainingDays > 59 and not leapYear then
        remainingDays = remainingDays + 1
    end
    
    local month = math.ceil(remainingDays / 30)
    local day = remainingDays % 30
    if day == 0 then
        day = 30
    end
    
    return year, month, day
end

-- Export the functions
return M