Module:Today/GA: Difference between revisions

From TSP Encyclopedia
Jump to navigation Jump to search
(ok)
Tag: Manual revert
No edit summary
Line 12: Line 12:
     month = tonumber(month)
     month = tonumber(month)
     day = tonumber(day)
     day = tonumber(day)
    return "Received: " .. tostring(year) .. " " .. tostring(month) .. " " .. tostring(day)
     -- Perform calculations here to convert the date
     -- Perform calculations here to convert the date
    local totalDays = (year - 1) * 365 + math.floor((year - 1) / 4) + day
--[[    local totalDays = (year - 1) * 365 + math.floor((year - 1) / 4) + day
     local monthIndex = math.floor((totalDays - 1) / daysPerMonth) + 1
     local monthIndex = math.floor((totalDays - 1) / daysPerMonth) + 1
     local dayInMonth = (totalDays - 1) % daysPerMonth + 1
     local dayInMonth = (totalDays - 1) % daysPerMonth + 1
      
      
     return monthIndex, dayInMonth
     return monthIndex, dayInMonth]]
end
end



Revision as of 19:49, 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)
	year = tonumber(year)
    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]]
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