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 10: | Line 10: | ||
:The current day of the year in the Gregorian calendar. |
:The current day of the year in the Gregorian calendar. |
||
First, |
First, define the following: |
||
;Earth leap year |
;Earth leap year |
||
<math mode="display">\text{year} \bmod 400 = 0</math> |
<math mode="display">\text{year} \bmod 400 = 0</math> |
||
| Line 18: | Line 18: | ||
;Keppel leap year (schedule 2) |
;Keppel leap year (schedule 2) |
||
<math mode="display">\text{year} \bmod 239 = 65</math> |
<math mode="display">\text{year} \bmod 239 = 65</math> |
||
;<code> |
;<code>earthYearLength</code> |
||
:If it is an Earth leap year, 366; else, 365. |
:If it is an Earth leap year, 366; else, 365. |
||
;<code> |
;<code>yearLength</code> |
||
:Start with 389. |
:Start with 389. |
||
:If it is a Keppel leap year (schedule 1), add one. |
:If it is a Keppel leap year (schedule 1), add one. |
||
| Line 30: | Line 30: | ||
;<code>year</code> |
;<code>year</code> |
||
<math mode="display">\text{year} - 892</math> |
<math mode="display">\text{year} - 892</math> |
||
:If <code> |
:If <code>yday</code> is less than 79, subtract one. |
||
;<code>ydayPre</code> |
;<code>ydayPre</code> |
||
<math mode="display">\frac{\text{ |
<math mode="display">\frac{\text{yearLength} * (\text{yday} - \text{rolloverOffset})}{\text{earthYearLength}} \bmod{\text{yearLength}}</math> |
||
| ⚫ | |||
;<code>yday</code> |
|||
<math mode="display">\text{ydayPre} \bmod{\text{ydayMaxEarth}}</math> |
|||
| ⚫ | |||
;<code>lythryd</code> |
;<code>lythryd</code> |
||
<math mode="display">\lceil \frac{\text{yday}}{32} \rceil</math> |
<math mode="display">\lceil \frac{\text{yday}}{32} \rceil</math> |
||
;<code>day</code> |
;<code>day</code> |
||
<math mode="display">\lfloor \text{yday} - \text{lythryd} * 32 |
<math mode="display">\lfloor \text{yday} - (\text{lythryd} - 1) * 32 \rfloor</math> |
||
<includeonly>[[Category:Modules: tesinormed]]</includeonly> |
<includeonly>[[Category:Modules: tesinormed]]</includeonly> |
||
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. ydayPre
\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