home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18366 < prev    next >
Encoding:
Internet Message Format  |  1992-12-15  |  1015 b 

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