Module:Today/GA

From TSP Encyclopedia
Revision as of 19:39, 11 August 2023 by Im a waffle1 (talk | contribs)
Jump to navigation Jump to search

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)
    -- 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)
    -- 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