CompuServe Thread

Day of the Week

1 messages in this thread
#24173From: John M. DlugoszFeb 20, 1990 3:28 AM
<<from memory>> int day_of_week (int MM, int DD, int YY) { static int mo[]= {0,3,3,6,1,4,6,2,5,0,3,5}; int total= (YY + YY/4 + mo[MM] + DD); if (YY/4 == 0 && MM < 3) //no leap yet total–; return total % 7; } This works on all dates in the 20th century, and if you use 101 for 2001 etc. it works in the 21st as well. One more term is needed if you want more centuraries.