Do anyone have an algorithm to produce the week day from a given date
? I need this badlly, please, SOMEONE, mail or post on comp.lang.c,
can be in any language (prolog or lisp - NOOOOOOO) but it whould be
nice if it's in C or pseudo-code.
Thanks in advance.
--
regards,
_____
|/asco (Antonio Vasconcelos, Lisbon Stock Exchange: va...@bvl.pt)
dayofweek(y, m, d) /* 1 <= m <= 12, y > 1752 (in the U.K.) */
{
static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
y -= m < 3;
return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
}
/*
dow(y,m,d){y-=m<3;return(y+y/4-y/100+y/400+"-bed=pen+mad."[m]+d)%7;}
This is not portable, but easy to learn by heart.
*/
--
T. Sakamoto
I'm thinking in the great time I'll spend trying to understend this
function. :-) Thanks a lot.
If the algorithm is still needed then check out the May 11, 1993 issue
of PC Magazine on pp. 396-406. The routine is there for years 0-9999
(Julian & Gregorian calendars.)
* - * - *
Paul-Joseph "Dragon" de Werk | Carpe diem.
Department of Computer Science | "First things first, but not
California State University, Fresno | necessarily in that order."
paul-jose...@CSUFresno.EDU | -- The Doctor, "Dr. Who"