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

From Amaranth Legacy, available at amaranth-legacy.community

This is the documentation page for Module:Keppel date

Converts the current (or provided) date to a Keppel date. Used by Template:Keppel date.

Formula

\begin{aligned} y_\oplus &= \text{Earth year} \\ d_\oplus &= \text{Earth day of year (fractional)} \\ \text{length}(y_\oplus) &= \begin{cases} 366 & (y_\oplus = 0 \pmod{4} \text{ and } y_\oplus \neq 0 \pmod{100}) \text{ or } y_\oplus = 0 \pmod{400} \\ 365 & \text{otherwise} \end{cases} \\ \text{offset}(y_\oplus) &= \text{length}(y_\oplus) - 287 \\ \text{length}(y_\text{K}) &= \begin{cases} 391 & y_\text{K} = 65 \pmod{239} \text{ and } y_\text{K} = 2 \pmod{4} \\ 390 & y_\text{K} = 65 \pmod{239} \text{ or } y_\text{K} = 2 \pmod{4} \\ 389 & \text{otherwise} \end{cases} \\ y_\text{K} &= \begin{cases} y_\oplus - 892 & d_\oplus - \text{offset}(y_\oplus) \geq \frac{\text{length}(y_\oplus)}{\text{length}(y_\oplus - 892)} \\ y_\oplus - 892 - 1 & d_\oplus - \text{offset}(y_\oplus) < \frac{\text{length}(y_\oplus)}{\text{length}(y_\oplus - 892)} \end{cases} \\ d_\text{K} &= (\frac{d_\oplus - \text{offset}(y_\oplus)}{\text{length}(y_\oplus)} \times \text{length}(y_\oplus) - 1) \bmod{\text{length}(y_\text{K})} + 1 \\ L &= \lfloor \frac{d_\text{K} - 1}{32} \rfloor + 1 \\ d_L &= \lfloor (d_\text{K} - 1) \bmod{32} \rfloor + 1 \end{aligned}