Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Day-of-week algorithm NEEDED!

160 views
Skip to first unread message

antonio vasconcelos

unread,
Apr 19, 1993, 2:20:05 PM4/19/93
to
[this posting is 'just-a-bit' off-the-topic, I'm sorry, but
comp.lang.c is the only programming group that I receive]

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)

Tomohiko Sakamoto

unread,
Apr 20, 1993, 3:59:17 AM4/20/93
to
In article <1993Apr19.1...@bvl.pt>,

va...@bvl.pt (antonio vasconcelos) says:
> 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.

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

antonio vasconcelos

unread,
Apr 22, 1993, 3:52:23 PM4/22/93
to
saka...@sm.sony.co.jp (Tomohiko Sakamoto) writes:
:
: /*

: 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.
: */
: --

I'm thinking in the great time I'll spend trying to understend this
function. :-) Thanks a lot.

-Dragon-

unread,
Apr 28, 1993, 5:34:17 PM4/28/93
to
va...@bvl.pt (antonio vasconcelos) writes:
:
: saka...@sm.sony.co.jp (Tomohiko Sakamoto) writes:
: :
: : /*
: : 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.
: : */
: : --
:
: 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"

cis.bha...@angelbroking.com

unread,
Jan 21, 2017, 2:09:48 AM1/21/17
to
This post helped me in 2017. Thank you

--

0 new messages