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

  1. Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!spool.mu.edu!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!mouse
  2. From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Date -> Day of week conversion
  5. Message-ID: <1992Dec17.220941.7308@thunder.mcrcim.mcgill.edu>
  6. Date: 17 Dec 92 22:09:41 GMT
  7. References: <Bz3I8K.LDJ@ccu.umanitoba.ca> <1992Dec15.021818.18355@sm.sony.co.jp>
  8. Organization: McGill Research Centre for Intelligent Machines
  9. Lines: 19
  10.  
  11. In article <1992Dec15.021818.18355@sm.sony.co.jp>, sakamoto@sm.sony.co.jp (Tomohiko Sakamoto) writes:
  12. > In article <Bz3I8K.LDJ@ccu.umanitoba.ca>, ummalik@ccu.umanitoba.ca (Ijaz Rashid Malik) says:
  13. >> Could someone please forward me algorithm to convert the date
  14. >> ([...]) to corresponding day of the week.
  15.  
  16. > Please try this:
  17. [...]
  18. >     return (y + y/4 - y/100 + y/400 + "-bed=pen+mad."[m] + d) % 7;
  19.  
  20. You would be much better off writing "\3\0\3\2\5\0\3\5\1\4\6\2\4"
  21. instead of "-bed=pen+mad."; that way you aren't dependent on ASCII.  (I
  22. assume ASCII is what it's intended to be used with; I didn't go testing
  23. it.)  For example, converting that string to EBCDIC, I find that it's
  24. equivalent to "\5\4\0\6\0\4\0\2\1\1\3\6\5" then....
  25.  
  26.                     der Mouse
  27.  
  28.                 mouse@larry.mcrcim.mcgill.edu
  29.