Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
You must create an account or log in to edit.

Module:Keppel date/doc

From Amaranth Legacy, available at amaranth-legacy.community

This is the documentation page for Module:Keppel date

Converts the current (or provided) date to a Keppel date. Used by Template:Keppel date.

Algorithm

Begin with the following inputs:

year
The current year in the Gregorian calendar.
yday
The current day of the year in the Gregorian calendar.

First, define the following:

Earth leap year

\text{year} \bmod 400 = 0 \text{year} \bmod 4 = 0\text{ and not }\text{year} \bmod 100 = 0

Keppel leap year (schedule 1)

\text{year} \bmod 4 = 2

Keppel leap year (schedule 2)

\text{year} \bmod 239 = 65

earthYearLength
If it is an Earth leap year, 366; else, 365.
yearLength
Start with 389.
If it is a Keppel leap year (schedule 1), add one.
If it is a Keppel leap year (schedule 2), add one.
rolloverOffset
If it is an Earth leap year, 79; else, 78.

To calculate the result:

year

\text{year} - 892

If yday is less than 79, subtract one.
yday

\frac{\text{yearLength} * (\text{yday} - \text{rolloverOffset})}{\text{earthYearLength}} \bmod{\text{yearLength}}

If this is less than or equal to zero, add yearLength.
lythryd

\lceil \frac{\text{yday}}{32} \rceil

day

\lfloor \text{yday} - (\text{lythryd} - 1) \times 32 \rfloor