Skip to content

Latest commit

 

History

History
19 lines (12 loc) · 1.03 KB

File metadata and controls

19 lines (12 loc) · 1.03 KB

"Program for computing Zeller's Congruence in C", my first gitHub upload.

This is an interesting algorithm that uses module theory and congruences to compute on what day of the week will a certain date (DD,MM,YYYY) coincide.

Zeller's Congruence

h = (q + ⌊(13(m + 1)) / 5⌋ + K + ⌊K / 4⌋ + ⌊J / 4⌋ - 2J) mod 7

Where:

  • h is the day of the week (0 = Saturday, 1 = Sunday, ..., 6 = Friday)
  • q is the day of the month
  • m is the month (January and February are counted as months 13 and 14 of the previous year) This I will explain later on
  • K is the year of the century (year % 100)
  • J is the zero-based century ( (year / 100))

Why are January and February counted as months 13 and 14 of the previous year?

  • For an easier year transition as the transition between years (from December to January) would require additional logic to handle the change in the year part of the formula.