home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!spool.mu.edu!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!mouse
- From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
- Newsgroups: comp.lang.c
- Subject: Re: Date -> Day of week conversion
- Message-ID: <1992Dec17.220941.7308@thunder.mcrcim.mcgill.edu>
- Date: 17 Dec 92 22:09:41 GMT
- References: <Bz3I8K.LDJ@ccu.umanitoba.ca> <1992Dec15.021818.18355@sm.sony.co.jp>
- Organization: McGill Research Centre for Intelligent Machines
- Lines: 19
-
- In article <1992Dec15.021818.18355@sm.sony.co.jp>, sakamoto@sm.sony.co.jp (Tomohiko Sakamoto) writes:
- > 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
- >> ([...]) to corresponding day of the week.
-
- > Please try this:
- [...]
- > return (y + y/4 - y/100 + y/400 + "-bed=pen+mad."[m] + d) % 7;
-
- You would be much better off writing "\3\0\3\2\5\0\3\5\1\4\6\2\4"
- instead of "-bed=pen+mad."; that way you aren't dependent on ASCII. (I
- assume ASCII is what it's intended to be used with; I didn't go testing
- it.) For example, converting that string to EBCDIC, I find that it's
- equivalent to "\5\4\0\6\0\4\0\2\1\1\3\6\5" then....
-
- der Mouse
-
- mouse@larry.mcrcim.mcgill.edu
-