In addition, perpetual calendars require no calculation by the user, and are essentially lookup tables.
A typical application is to calculate the day of the week on which someone was born or a specific event occurred.
The day designated with 7 may also be counted as 0, by applying the arithmetic modulo 7, which calculates the remainder of a number after division by 7.
Eventually, one ends up with a day-count to which one applies modulo 7 to determine the day of the week of the date.
None of the methods given here perform range checks, so unreasonable dates will produce erroneous results.
In the proleptic Gregorian calendar, (so called because it wasn't devised until 1582), 1 BC starts on Saturday.
Note that the date (and hence the day of the week) in the Revised Julian and Gregorian calendars is the same from 14 October 1923 to 28 February AD 2800 inclusive and that for large years it may be possible to subtract 6300 or a multiple thereof before starting so as to reach a year which is within or closer to the table.
Enter the table with the Julian year, and just before the final division add 50 and subtract the quotient noted above.
To find the Dominical Letter, calculate the day of the week for either 1 January or 1 October.
For a leap year, the Sunday letter thus found is the one which applies to March to December.
Carl Friedrich Gauss described a method for calculating the day of the week for 1 January in any given year in a handwritten note in a collection of astronomical tables.
[6] Compared to Rata Die, the result helps simplify the counting of years.
The table of month offsets show a divergence in February due to the leap year.
A common technique (later used by Zeller) is to shift the month to start with March, so that the leap day is at the tail of the counting.
This formula was also converted into graphical and tabular methods for calculating any day of the week by Kraitchik and Schwerdtfeger.
The formula for the Gregorian calendar is[8] where In Zeller's algorithm, the months are numbered from 3 for March to 14 for February.
The year is assumed to begin in March; this means, for example, that January 1995 is to be treated as month 13 of 1994.
Although explicit in asserting that his method also works for Old Style dates, his example reproduced below to determine that "1676, February 23" is a Wednesday only works on a Julian calendar which starts the year on January 1, instead of March 25 as on the "Old Style" Julian calendar.
For 'New Style' (which began 14 September 1752) divide by 4, take overplus [surplus] from 3, multiply remainder by 2.
Month-item: If it begins or ends with a vowel, subtract the number, denoting its place in the year, from 10.
The final result gives the day of the week, "0" meaning Sunday, "1" Monday, and so on.
Carroll's method however assumes 1 January as the first day of the year, thus he fails to arrive at the correct answer, namely "Friday".
It is noteworthy that those who have republished Carroll's method have failed to point out his error, most notably Martin Gardner.
In 1990, Michael Keith and Tom Craver published the foregoing expression that seeks to minimize the number of keystrokes needed to enter a self-contained function for converting a Gregorian date into a numerical day of the week.
Shortly afterwards, Hans Lachman streamlined their algorithm for ease of use on low-end devices.
As designed originally for four-function calculators, his method needs fewer keypad entries by limiting its range either to A.D. 1905–2099, or to historical Julian dates.
On Motorola 68000-based devices, there is similarly less need of either processor registers or opcodes, depending on the intended design objective.
Sakamoto also simultaneously posted a more obfuscated version: This version encodes the month offsets in the string and as a result requires a computer that uses standard ASCII to run the algorithm correctly, reducing its portability.
In addition, both algorithms omit int type declarations, which is allowed in the original K&R C but not allowed in ANSI C. (Tøndering's algorithm is, again, similar in structure to Zeller's congruence and Keith's short code, except that the month-related component is 31*m/12.
Sakamoto's is somewhere between the Disparate Gaussian and the Schwerdtfeger's algorithm, apparently unaware of the expression form.)