Weekday Formula
I have found two formulas to calculate the weekday (w) of any date after the Gregorian calendar reform*.
The first formula is from the calendar FAQ:
w = [day + y + (y/4) - (y/100) + (y/400) + (31m/12)] mod 7
A = (14 - month)/12
y = year - A
m = month + 12A - 2
A similar slightly simpler formula was presented by Christoph Zeller in 1885:
w = [ day + 2.6(month+1) + 5y/4 + c/4 - 2c - 1 ] mod 7
y = year without first two digits (0...99)
c = first two digits of the year (e.g. 19)
In this formula January and February are treated as being the 13. and 14. month of the previous year.
*All divisions in the calculations are just taking the integers as results, the resulting numbers mean: 0 = Sunday, 1 = Monday, etc.