home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!agate!ames!sun-barr!sh.wide!wnoc-tyo-news!scslwide!wsgw!wsservra!sakamoto
- From: sakamoto@sm.sony.co.jp (Tomohiko Sakamoto)
- Newsgroups: comp.lang.c
- Subject: Re: Date -> Day of week conversion
- Message-ID: <1992Dec15.021818.18355@sm.sony.co.jp>
- Date: 15 Dec 92 02:18:18 GMT
- References: <Bz3I8K.LDJ@ccu.umanitoba.ca>
- Sender: news@sm.sony.co.jp (Usenet News System)
- Reply-To: sakamoto@sm.sony.co.jp
- Organization: Workstation Div., Supermicro Systems Group, Sony Corporation
- Lines: 19
- Nntp-Posting-Host: sak3
-
- In article <Bz3I8K.LDJ@ccu.umanitoba.ca>,
- ummalik@ccu.umanitoba.ca (Ijaz Rashid Malik) says:
- >
- > Could someone please forward me algorithm to convert the date (in dd.mm.yy
- > or yy.mm.dd format, but assume individual fields can be obtained as integers)
- > to corresponding day of the week.
-
- Please try this:
- /*
- * 1 <= m <= 12, y > 1752 (in the U.K.)
- */
- dayofweek(y, m, d)
- {
- y -= m < 3;
- return (y + y/4 - y/100 + y/400 + "-bed=pen+mad."[m] + d) % 7;
- }
-
- --
- T. Sakamoto
-