Perpetual Calendar - Perpetual Calendar Algorithms

Perpetual Calendar Algorithms

Perpetual calendar use algorithms to compute the day of the week for any given year, month, and day of month. Even though the individual operations in the formulas can be very efficiently implemented in software (requiring no processor-intensive floating-point operations), they are too complicated for most people to perform all of the arithmetic mentally. Perpetual calendar designers hide the complexity in tables to simplify their use.

A perpetual calendar employs a table for finding which of fourteen yearly calendars to use. A table for the Gregorian calendar expresses its 400-year grand cycle: 303 common years and 97 leap years total to 146,097 days, or exactly 20,871 weeks. This cycle breaks down into one 100-year period with 25 leap years, making 36,525 days, or one day less than 5,218 full weeks; and three 100-year periods with 24 leap years each, making 36,524 days, or two days less than 5,218 full weeks.

Within each 100-year block, the cyclic nature of the Gregorian calendar proceeds in exactly the same fashion as its Julian predecessor: A common year begins and ends on the same day of the week, so the following year will begin on the next successive day of the week. A leap year has one more day, so the year following a leap year begins on the second day of the week after the leap year began. Every four years, the starting weekday advances five days, so over a 28-year period it advances 35, returning to the same place in both the leap year progression and the starting weekday. This cycle completes three times in 84 years, leaving 16 years in the fourth, incomplete cycle of the century.

A major complicating factor in constructing a perpetual calendar algorithm is the peculiar and variable length of February, which was at one time the last month of the year, leaving the first 11 months March through January with a five-month repeating pattern: 31, 30, 31, 30, 31, ..., so that the offset from March of the starting day of the week for any month could be easily determined. Zeller's congruence, a well-known algorithm for finding the day of week for any date, explicitly defines January and February as the "13th" and "14th" months of the previous year in order to take advantage of this regularity, but the month-dependent calculation is still very complicated for mental arithmetic:

Instead, a table-based perpetual calendar provides a simple look-up mechanism to find offset for the day of week for the first day of each month. To simplify the table, in a leap year January and February must either be treated as a separate year or have extra entries in the month table:

Month Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
Add 0 3 3 6 1 4 6 2 5 0 3 5
For leap years 6 2

Read more about this topic:  Perpetual Calendar

Famous quotes containing the words perpetual and/or calendar:

    Fascism, the more it considers and observes the future and the development of humanity, quite apart from political considerations of the moment, believes neither in the possibility nor the utility of perpetual peace.
    Benito Mussolini (1883–1945)

    To divide one’s life by years is of course to tumble into a trap set by our own arithmetic. The calendar consents to carry on its dull wall-existence by the arbitrary timetables we have drawn up in consultation with those permanent commuters, Earth and Sun. But we, unlike trees, need grow no annual rings.
    Clifton Fadiman (b. 1904)