Module:Today/GA: Difference between revisions

From TSP Encyclopedia
Jump to navigation Jump to search
No edit summary
(WORK)
Line 1: Line 1:
------ IMPERIAL GALACTYAN CALENDAR ------
------ IMPERIAL GALACTYAN CALENDAR ------


local M = {}
local CustomCalendar = {}


-- Define the number of months and days in each month
-- Define month names and days per month
local numMonths = 10
local monthNames = {
    "Month 1", "Month 2", "Month 3", "Month 4", "Month 5",
    "Month 6", "Month 7", "Month 8", "Month 9", "Month 10"
}
local daysPerMonth = 59
local daysPerMonth = 59


-- Function to convert Gregorian date to 10-month calendar date
-- Function to convert Gregorian date to custom calendar date
function M.convertTo10MonthCalendar(year, month, day)
function CustomCalendar.convertToCustomCalendar(gregorianYear, gregorianMonth, gregorianDay)
year = tonumber(year)
     -- Conversion logic goes here
    month = tonumber(month)
    day = tonumber(day)
    return "Received: " .. tostring(year) .. " " .. tostring(month) .. " " .. tostring(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]]
     -- Calculate total days passed in Gregorian calendar
end
     local totalDays = (gregorianYear - 1) * 365 + math.floor((gregorianYear - 1) / 4) -- Basic leap year handling
 
-- 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)
     -- Add days of the months that have passed
     if remainingDays > 59 and not leapYear then
     for i = 1, gregorianMonth - 1 do
         remainingDays = remainingDays + 1
         totalDays = totalDays + daysInMonth[i]
     end
     end
      
      
     local month = math.ceil(remainingDays / 30)
    -- Add remaining days of the current month
     local day = remainingDays % 30
    totalDays = totalDays + gregorianDay
    if day == 0 then
   
        day = 30
    -- Calculate custom calendar year and month
    end
     local customYear = math.floor(totalDays / (10 * daysPerMonth)) + 1
     local customMonth = math.floor((totalDays - 1) % daysPerMonth) + 1
      
      
     return year, month, day
     return customYear, customMonth
end
end


-- Export the functions
return CustomCalendar
return M

Revision as of 20:20, 11 August 2023

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

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

local CustomCalendar = {}

-- Define month names and days per month
local monthNames = {
    "Month 1", "Month 2", "Month 3", "Month 4", "Month 5",
    "Month 6", "Month 7", "Month 8", "Month 9", "Month 10"
}
local daysPerMonth = 59

-- Function to convert Gregorian date to custom calendar date
function CustomCalendar.convertToCustomCalendar(gregorianYear, gregorianMonth, gregorianDay)
    -- Conversion logic goes here
    
    -- Calculate total days passed in Gregorian calendar
    local totalDays = (gregorianYear - 1) * 365 + math.floor((gregorianYear - 1) / 4)  -- Basic leap year handling
    
    -- Add days of the months that have passed
    for i = 1, gregorianMonth - 1 do
        totalDays = totalDays + daysInMonth[i]
    end
    
    -- Add remaining days of the current month
    totalDays = totalDays + gregorianDay
    
    -- Calculate custom calendar year and month
    local customYear = math.floor(totalDays / (10 * daysPerMonth)) + 1
    local customMonth = math.floor((totalDays - 1) % daysPerMonth) + 1
    
    return customYear, customMonth
end

return CustomCalendar