How weekdays are found
The Gregorian calendar repeats every 400 years (146,097 days, exactly 20,871 weeks), so any date’s weekday can be computed. A quick mental method is Zeller’s congruence:
h = (q + ⌊13(m+1)/5⌋ + K + ⌊K/4⌋ + ⌊J/4⌋ + 5J) mod 7
where q is the day, m the month (March = 3 … February = 14 of the previous year), K the year of the century and J the century. h = 0 is Saturday.