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 31: | Line 31: | ||
<math mode="display">\text{year} - 892</math> |
<math mode="display">\text{year} - 892</math> |
||
:If <code>yday</code> is less than 79, subtract one. |
:If <code>yday</code> is less than 79, subtract one. |
||
;<code> |
;<code>yday</code> |
||
<math mode="display">\frac{\text{yearLength} * (\text{yday} - \text{rolloverOffset})}{\text{earthYearLength}} \bmod{\text{yearLength}}</math> |
<math mode="display">\frac{\text{yearLength} * (\text{yday} - \text{rolloverOffset})}{\text{earthYearLength}} \bmod{\text{yearLength}}</math> |
||
:If <code>yday</code> is less than or equal to zero, then add <code>yearLength</code>. |
:If <code>yday</code> is less than or equal to zero, then add <code>yearLength</code>. |
||
Revision as of 02:51, March 5, 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, 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
ydayis less than 79, subtract one. yday
\frac{\text{yearLength} * (\text{yday} - \text{rolloverOffset})}{\text{earthYearLength}} \bmod{\text{yearLength}}
- If
ydayis less than or equal to zero, then addyearLength. lythryd
\lceil \frac{\text{yday}}{32} \rceil
day
\lfloor \text{yday} - (\text{lythryd} - 1) * 32 \rfloor