Zeller's congruence

Zeller's congruence is an algorithm devised by Christian Zeller to calculate the day of the week for any Julian or Gregorian calendar date. It can be considered to be based on the conversion between Julian day and the calendar date.

Formula

For the Gregorian calendar, Zeller's congruence is

for the Julian calendar it is

where

NOTE: In this algorithm January and February are counted as months 13 and 14 of the previous year. E.g. if it is 2 February 2010, the algorithm counts the date as the second day of the fourteenth month of 2009 (02/14/2009 in DD/MM/YYYY format)

For an ISO week date Day-of-Week d (1 = Monday to 7 = Sunday), use

Implementation in software

The formulas rely on the mathematician's definition of modulo division, which means that −2 mod 7 is equal to positive 5. Unfortunately, the way most computer languages implement the remainder function, −2 mod 7 returns a result of 2. So, to implement Zeller's congruence on a computer, the formulas should be altered slightly to ensure a positive numerator. The simplest way to do this is to replace − 2J by + 5J and J by + 6J. So the formulas become:

for the Gregorian calendar, and

for the Julian calendar.

One can readily see that, in a given year, March 1 (if that is a Saturday, then March 2) is a good test date; and that, in a given century, the best test year is that which is a multiple of 100.

Zeller used decimal arithmetic, and found it convenient to use J and K in representing the year. But when using a computer, it is simpler to handle the modified year Y, which is Y - 1 during January and February:

for the Gregorian calendar (in this case there is no possibility of overflow because ), and

for the Julian calendar.

Analysis

These formulas are based on the observation that the day of the week progresses in a predictable manner based upon each subpart of that date. Each term within the formula is used to calculate the offset needed to obtain the correct day of the week.

For the Gregorian calendar, the various parts of this formula can therefore be understood as follows:

The reason that the formula differs for the Julian calendar is that this calendar does not have a separate rule for leap centuries and is offset from the Gregorian calendar by a fixed number of days each century.

Since the Gregorian calendar was adopted at different times in different regions of the world, the location of an event is significant in determining the correct day of the week for a date that occurred during this transition period. This is only required through 1929, as this was the last year that the Julian calendar was still in use by any country on earth, and thus is not required for 1930 or later.

The formulae can be used proleptically, but with care for years before Year 0. To accommodate this, one can add a sufficient multiple of 400 Gregorian or 28 Julian years.

Examples

For 1 January 2000, the date would be treated as the 13th month of 1999, so the values would be:

So the formula evaluates as .

(The 36 comes from , truncated to an integer.)

However, for 1 March 2000, the date is treated as the 3rd month of 2000, so the values become

so the formula evaluates as .

See also

References

  1. The every five months rule only applies to the twelve months of a year.

Each of these four similar imaged papers deals firstly with the day of the week and secondly with the date of Easter Sunday, for the Julian and Gregorian Calendars. The pages link to translations into English.

External links

This article is issued from Wikipedia - version of the 11/30/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.