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) Replaced content with "__NOTOC__ Converts the current (or provided) date to a Keppel date. Used by Template:Keppel date." Tags: Replaced 2017 source edit |
||
| Line 2: | Line 2: | ||
Converts the current (or provided) date to a Keppel date. |
Converts the current (or provided) date to a Keppel date. |
||
Used by [[Template:Keppel date]]. |
Used by [[Template:Keppel date]]. |
||
==Algorithm== |
|||
Begin with the following inputs: |
|||
;<code>year</code> |
|||
:The current year in the Gregorian calendar. |
|||
;<code>yday</code> |
|||
:The current day of the year in the Gregorian calendar. |
|||
First, define the following: |
|||
;Earth leap year |
|||
<math mode="display">\text{year} \bmod 400 = 0</math> |
|||
<math mode="display">\text{year} \bmod 4 = 0\text{ and not }\text{year} \bmod 100 = 0</math> |
|||
;Keppel leap year (schedule 1) |
|||
<math mode="display">\text{year} \bmod 4 = 2</math> |
|||
;Keppel leap year (schedule 2) |
|||
<math mode="display">\text{year} \bmod 239 = 65</math> |
|||
;<code>earthYearLength</code> |
|||
:If it is an Earth leap year, 366; else, 365. |
|||
;<code>yearLength</code> |
|||
: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. |
|||
;<code>rolloverOffset</code> |
|||
:If it is an Earth leap year, 79; else, 78. |
|||
To calculate the result: |
|||
;<code>year</code> |
|||
<math mode="display">\text{year} - 892</math> |
|||
:If <code>yday</code> is less than 79, subtract one. |
|||
;<code>yday</code> |
|||
<math mode="display">\frac{\text{yearLength} * (\text{yday} - \text{rolloverOffset})}{\text{earthYearLength}} \bmod{\text{yearLength}}</math> |
|||
:If this is less than or equal to zero, add <code>yearLength</code>. |
|||
;<code>lythryd</code> |
|||
<math mode="display">\lceil \frac{\text{yday}}{32} \rceil</math> |
|||
;<code>day</code> |
|||
<math mode="display">\lfloor \text{yday} - (\text{lythryd} - 1) \times 32 \rfloor</math> |
|||
<includeonly>[[Category:Modules: tesinormed]]</includeonly> |
|||
Revision as of 08:25, September 17, 2025
Converts the current (or provided) date to a Keppel date. Used by Template:Keppel date.