Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!news.funet.fi!uwasa.fi!ts From: ts@uwasa.fi (Timo Salmi) Newsgroups: comp.lang.pascal Subject: Re: Algorithm needed Message-ID: <1990Oct10.175221.17285@uwasa.fi> Date: 10 Oct 90 17:52:21 GMT References: <3334@vela.acs.oakland.edu> Organization: University of Vaasa Lines: 33 In article <3334@vela.acs.oakland.edu> moconnor@argo.acs.oakland.edu writes: >Could someone please mail me code such that given a date (something >like, say, October 10th, 1990), it tells me the day of the week? >Am demonstrating laziness... oh well... 3. ***** Q: I want code that gives the weekday of the given date. A1: There is a wkdayfn function in /pc/ts/tspas22.arc Turbo Pascal units collection to give the modern weekday based on Zeller's congruence. Also you can find a more extensive Julian and Gregorian weekday algorithm in Dr.Dobbs Journal, June 1989, p. 148. Furthermore Press & Flannery & al, Numerical Recipes, has the weekday code. A2: Some will recommend the following kludge. Store the current date, change it, and let MsDos get you the weekday. This is a bad suggestion. On top of being sloppy programming, there are several snags. The trick works only for years 1980-2079. A crash the program may leave the clock at a wrong date. And even if multitasking is rare, in a multitasking environment havoc may result for the other tasks. The wares (/pc/ts/tspas22.arc) are available by anonymous ftp from chyde.uwasa.fi, Vaasa, Finland, 128.214.12.3, or by using our mail server (use the latter if, and only if you don't have anonymous ftp). If you are not familiar with anonymous ftp or mail servers, I am prepared send prerecorded instructions on request (provided that your email address is reachable). ................................................................... Prof. Timo Salmi (Moderating at anon. ftp site 128.214.12.3) School of Business Studies, University of Vaasa, SF-65101, Finland Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun