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: Difference between revisions

From Amaranth Legacy, available at amaranth-legacy.community
Content deleted Content added
No edit summary
Tag: 2017 source edit
No edit summary
Tag: 2017 source edit
Line 12: Line 12:
First, we define the following:
First, we 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>
:<math mode="display">\text{year} \bmod 4 = 0\text{ and not }\text{year} \bmod 100 = 0</math>
<math mode="display">\text{year} \bmod 4 = 0\text{ and not }\text{year} \bmod 100 = 0</math>
;Keppel leap year (schedule 1)
;Keppel leap year (schedule 1)
:<math mode="display">\text{year} \bmod 4 = 2</math>
<math mode="display">\text{year} \bmod 4 = 2</math>
;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>ydayMaxEarth</code>
;<code>ydayMaxEarth</code>
:If it is an Earth leap year, 366; else, 365.
:If it is an Earth leap year, 366; else, 365.
Line 29: Line 29:
To calculate the result:
To calculate the result:
;<code>year</code>
;<code>year</code>
:<math mode="display">\text{year} - 892</math>
<math mode="display">\text{year} - 892</math>
: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>
:<math mode="display">\frac{\text{ydayMax} * (\text{yday} - \text{rolloverOffset})}{\text{ydayMaxEarth}}</math>
<math mode="display">\frac{\text{ydayMax} * (\text{yday} - \text{rolloverOffset})}{\text{ydayMaxEarth}}</math>
;<code>yday</code>
;<code>yday</code>
:<math mode="display">\text{ydayPre} \bmod{\text{ydayMaxEarth}}</math>
<math mode="display">\text{ydayPre} \bmod{\text{ydayMaxEarth}}</math>
:If <code>yday</code> is between zero (inclusive) and one (exclusive), then <code>yday</code> is <code>ydayMax</code>.
:If <code>yday</code> is between zero (inclusive) and one (exclusive), then <code>yday</code> is <code>ydayMax</code>.
;<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 \bmod{32} \rfloor</math>
<math mode="display">\lfloor \text{yday} - \text{lythryd} * 32 \bmod{32} \rfloor</math>
<includeonly>[[Category:Modules: tesinormed]]</includeonly>
<includeonly>[[Category:Modules: tesinormed]]</includeonly>

Revision as of 22:01, 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:

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

ydayMaxEarth
If it is an Earth leap year, 366; else, 365.
ydayMax
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 ydayPre is less than zero, subtract one.
ydayPre

\frac{\text{ydayMax} * (\text{yday} - \text{rolloverOffset})}{\text{ydayMaxEarth}}

yday

\text{ydayPre} \bmod{\text{ydayMaxEarth}}

If yday is between zero (inclusive) and one (exclusive), then yday is ydayMax.
lythryd

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

day

\lfloor \text{yday} - \text{lythryd} * 32 \bmod{32} \rfloor