Module:Keppel date/doc: Difference between revisions
From Amaranth Legacy, available at amaranth-legacy.community
More actions
Content deleted Content added
Tesinormed (talk | contribs) No edit summary Tag: 2017 source edit |
Tesinormed (talk | contribs) No edit summary Tag: 2017 source edit |
||
| Line 23: | Line 23: | ||
To calculate the result: |
To calculate the result: |
||
;<code>year</code> |
;<code>year</code> |
||
:<math mode="display">\text{year} - 892</math> |
|||
:Start with the current year minus 892. |
|||
:If <code>ydayPre</code> is less than zero, subtract one. |
:If <code>ydayPre</code> is less than zero, subtract one. |
||
;<code>ydayPre</code> |
;<code>ydayPre</code> |
||
Revision as of 21:48, March 4, 2025
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, we define the following:
ydayMaxEarth- If it is an Earth leap year, 366; else, 365.
ydayMax- Start with 389.
- If it is an Earth leap year, add one.
- 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
ydayPreis less than zero, subtract one. ydayPre- \frac{\text{ydayMax} * (\text{yday} - \text{rolloverOffset})}{\text{ydayMaxEarth}}
yday- \text{ydayPre} \pmod{\text{ydayMaxEarth}}
- If
ydayis between zero (inclusive) and one (exclusive), thenydayisydayMax. lythryd- \lceil \frac{\text{yday}}{32} \rceil
day- \lfloor \text{yday} - \text{lythryd} * 32 \pmod{32} \rfloor