Well, given any starting date for which you know the day of week, you would work
with the difference in days modulo 7. But of course the real issue is how to
count up that difference in days. All you really need is the leap year rules:
1) Every year divisible by 4 is a leap year, EXCEPT
2) Every year divisible by 100 is NOT a leap year, EXCEPT
3) Every year divisible by 400 IS a leap year, EXCEPT
4) (I don't know where the next exception falls, but these first
3 should be good enough for anything since Year 0, at least)
So in essence you apply the above rules to count the number of days in each year
until you get to the target year, then start counting days per month (watch out
for February) until you get to the target month, etc.
This is a simple-minded way to go about it of course, and somewhat less trivial
to code correctly than it probably sounds, but it is good enough for reasonable
time spans. Low-level system utilities which must do this sort of calculation
as quickly as possible use highly optimized code and every mathematical trick in
the book.
HTH,
-rick-