home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:18348 comp.lang.pascal:7465 comp.lang.c++:17944
- Newsgroups: comp.lang.c,comp.lang.pascal,comp.lang.c++
- Path: sparky!uunet!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!darwin.sura.net!spool.mu.edu!yale.edu!yale!gumby!destroyer!sol.ctr.columbia.edu!eff!news.byu.edu!ux1!fcom.cc.utah.edu!park.uvcc.edu!ns.novell.com!novdpd!novell.com!jhaide
- From: jhaide@novell.com (Janos A. Haide)
- Subject: Re: Date -> Day of week conversion
- Message-ID: <jhaide.22.724104190@novell.com>
- Lines: 31
- Sender: news@novell.com
- Nntp-Posting-Host: aus-jhaide
- Organization: Novell, Inc. --Austin
- References: <Bz3I8K.LDJ@ccu.umanitoba.ca>
- Date: Fri, 11 Dec 1992 20:03:10 GMT
-
- In article <Bz3I8K.LDJ@ccu.umanitoba.ca> ummalik@ccu.umanitoba.ca (Ijaz Rashid Malik) writes:
- >
- >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.
- >
- >Thanks very much.
- >
- >Malik
-
- Since you have crossposted in comp.lang.c I'd say that you can simply
- initialize a few fields on a struct tm and then apply mktime() on it.
- One of the fields will be set to the week of day.
-
- As far as a generic formula goes, here is one I've seen a few days ago
- (PASCAL-ish):
-
- N:=(Trunc(M*2.6-0.1)+D+Y+Y div 4+5*C+C div 4) mod 7
-
- Where:
- D = day of month
- Y = year of the century.
- C = century.
- M = Month - 2.
- ( January M=11 , February M=12 )
-
- Result is an 0-6 integer.
-
- Later,
- Janos
- jhaide@novell.com
-