Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!usenet From: hughes@math.berkeley.edu (Eric Hughes) Newsgroups: comp.binaries.ibm.pc.d Subject: Re: Looking for D.O.W. algorithm Keywords: weekday Message-ID: <1989Sep18.165034.19753@agate.berkeley.edu> Date: 18 Sep 89 16:50:34 GMT References: <6470@hubcap.clemson.edu> <1839@sactoh0.UUCP> <766@chyde.uwasa.fi> Sender: usenet@agate.berkeley.edu (USENET Administrator;;;;ZU44) Reply-To: hughes@math.berkeley.edu (Eric Hughes) Organization: UC Berkeley Math Dept Lines: 19 In-reply-to: ts@chyde.uwasa.fi (Timo Salmi LASK) In article <766@chyde.uwasa.fi>, ts@chyde (Timo Salmi LASK) writes: >This is a subject that seems to pop up about every weekday:-) The >bios call only returns the *current* weekday, but for *any* weekday >an algorithm is needed. The standard trick under MSDOS is to save the current date, then set the date to the desired one, get the day of the week, and finally reset the date to the real one. Alternatively, use a julian date routine, divide the resulting number by seven, and use the remainder to get the day of the week; this requires calibration to a known date-day pair. Oh, and if you want to do this for dates previous to the 15th century, you'll need to take into account various calendar adjustments that were made. :-) Eric Hughes hughes@math.berkeley.edu ucbvax!math!hughes