[comp.sources.wanted] day of week algorithm

dfm@sagepub.UUCP (David F. McCune) (02/28/89)

I used to have a C function that would compute the day
of the week from any given date.  You could pass it a
date in the form yymmdd, and it would return an int
in the range 0 - 7, where 0 was invalid date, 1 was
Sunday, 2 was Monday, and so on.

But I've lost the function.  Can anyone email me such an
animal?  Or even just describe the algorithm for computing
the day of the week?  Thanks much!

-- David

-- 
                 David McCune, Sage Publications, Inc.
           2111 West Hillcrest Drive, Newbury Park, CA 91320
        voice: (805) 499-0721       uucp: ...srhqla!sagepub!dfm
     "No!! I just wanted you to remove the file named S-T-A-R...."

walker@hpl-opus.HP.COM (Rick Walker) (03/03/89)

/ hpl-opus:comp.sources.wanted / dfm@sagepub.UUCP (David F. McCune) /  8:47 pm  Feb 27, 1989 /

>	I used to have a C function that would compute the day
>	of the week from any given date.  You could pass it a
>	date in the form yymmdd, and it would return an int
>	in the range 0 - 7, where 0 was invalid date, 1 was
>	Sunday, 2 was Monday, and so on.
>	

Such a routine appears on page 10 of "Numerical Recipes in C",
by William H. Press, et al., Cambridge University Press, 1988.

I'm pretty sure that one of Knuth's books has the algorithm also.

-Rick Walker