All Categories

Time & Calendar

Calendar rules, weekday and date algorithms, clock and astronomical timekeeping.

Leap Year Rule

Basic
leap    (ymod4=0    ymod1000)    (ymod400=0)\text{leap} \iff (y \bmod 4 = 0 \;\wedge\; y \bmod 100 \neq 0) \;\vee\; (y \bmod 400 = 0)

Tests whether a Gregorian year has 366 days.

View details

Clock Hand Angle

Basic
θ=30H5.5M\theta = |30H - 5.5M|

Angle between the hour and minute hands of an analog clock.

View details

Zeller's Congruence

Advanced
h=(q+13(m+1)5+K+K4+J4+5J)mod7h = \left(q + \left\lfloor\tfrac{13(m+1)}{5}\right\rfloor + K + \left\lfloor\tfrac{K}{4}\right\rfloor + \left\lfloor\tfrac{J}{4}\right\rfloor + 5J\right) \bmod 7

Finds the day of the week for any Gregorian date.

View details

Day of the Week from a Birthdate

Intermediate
W=(d+2.6m0.2+y+y4+c42c)mod7W = \left(d + \left\lfloor 2.6m - 0.2 \right\rfloor + y + \left\lfloor\tfrac{y}{4}\right\rfloor + \left\lfloor\tfrac{c}{4}\right\rfloor - 2c\right) \bmod 7

Gauss's weekday formula — find which day of the week any birthdate fell on.

View details

Julian Day Number

Advanced
JDN=365.25(Y+4716)+30.6001(M+1)+D+B1524JDN = \left\lfloor 365.25(Y+4716) \right\rfloor + \left\lfloor 30.6001(M+1) \right\rfloor + D + B - 1524

Continuous day count used by astronomers to compare dates.

View details

Days Between Two Dates

Intermediate
Δ=JDN2JDN1\Delta = JDN_2 - JDN_1

Number of days separating two calendar dates.

View details

Age in Years

Basic
A=JDNtodayJDNbirth365.2425A = \left\lfloor \dfrac{JDN_{today} - JDN_{birth}}{365.2425} \right\rfloor

Whole years elapsed since a birth date.

View details

Unix Timestamp

Intermediate
t=86400d+3600h+60m+st = 86400\,d + 3600h + 60m + s

Seconds elapsed since 1970-01-01 00:00:00 UTC (the epoch).

View details

Sidereal Day

Advanced
Tsid=Tsol1+Tsol/TyrT_{sid} = \dfrac{T_{sol}}{1 + T_{sol}/T_{yr}}

Earth's rotation period measured against the stars, not the Sun.

View details

ISO Week Number

Advanced
W=dowd+107W = \left\lfloor \dfrac{d_o - w_d + 10}{7} \right\rfloor

ISO-8601 week of the year (weeks start on Monday).

View details

Local Time from UTC

Basic
tlocal=tUTC+Δt_{local} = t_{UTC} + \Delta

Convert Coordinated Universal Time to a local zone.

View details

Equation of Time

Advanced
E9.87sin2B7.53cosB1.5sinBE \approx 9.87\sin 2B - 7.53\cos B - 1.5\sin B

Difference between sundial (apparent) and clock (mean) time.

View details

Period & Frequency

Basic
T=1fT = \dfrac{1}{f}

A repeating event's period is the reciprocal of its frequency.

View details

Ordinal Day of Year

Intermediate
N=275M9kM+912+D30N = \left\lfloor \dfrac{275M}{9} \right\rfloor - k\left\lfloor \dfrac{M+9}{12} \right\rfloor + D - 30

Day-of-year number (1–366) for a given date.

View details

Easter Date (Computus)

Advanced
d=(19a+b)mod30,a=ymod19d = (19a + b) \bmod 30,\quad a = y \bmod 19

Core step of the Gregorian algorithm locating the Paschal full moon.

View details