Boye.Tranum@newcastle.ac.uk (B. Tranum) (02/15/91)
I need to find out the name of the day (Monday, Tuesday etc.) from the date and the year. For example, which day was 10-02-91. - It was a Sunday. Does anybody have a nice routine, in Pascal or in English, to do this. I would be very pleased if you could help me. -- Many Thanks Boye Tranum Turing : q1y9e Internet : B. Tranum@newcastle.ac.uk JANET : B.Tranum@uk.ac.newcastle UUCP : ...!ukc!newcastle.ac.uk!B.Tranum
ts@uwasa.fi (Timo Salmi) (02/18/91)
In article <1991Feb15.121713.10075@newcastle.ac.uk> Boye.Tranum@newcastle.ac.uk (B. Tranum) writes: >I need to find out the name of the day (Monday, Tuesday etc.) from the date >and the year. For example, which day was 10-02-91. - It was a Sunday. > >Does anybody have a nice routine, in Pascal or in English, to do this. I would >be very pleased if you could help me. You'll find "all about" this FAQ in /pc/ts/tsfaq17.arc, and the routine in /pc/ts/tspa23##.arc (## = 40, 50, 55, 60). Available by anonymous ftp or mail server from our site. ................................................................... Prof. Timo Salmi Moderating at garbo.uwasa.fi anonymous ftp archives 128.214.12.37 School of Business Studies, University of Vaasa, SF-65101, Finland Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun
simpson@aplcen.apl.jhu.edu (Simpson David Grant) (02/19/91)
In article <1991Feb15.121713.10075@newcastle.ac.uk> Boye.Tranum@newcastle.ac.uk (B. Tranum) writes: >I need to find out the name of the day (Monday, Tuesday etc.) from the date >and the year. For example, which day was 10-02-91. - It was a Sunday. > >Does anybody have a nice routine, in Pascal or in English, to do this. I would >be very pleased if you could help me. > There is an article in the latest issue of the Journal of Recreational Mathematics that has a routine for doing this. Given a month m, day d, and year y in the Gregorian calendar, the day of week D (where 0=Sunday, 1=Monday, ..., 6=Saturday) can be found from D = ((23*m/9)+d+4+y+(z/4)-(z/100)+(z/400)-2(if m>=3)) mod 7 where z = y-1 if m<3 z = y otherwise (See "The Ultimate Perpetual Calendar" by Keith & Craver, J. Rec. Math., v22 n4 p280). They include a (if you'll excuse this) C function: dayofweek (y,m,d) { return ((23*m/9+d+4+(m<3?y--:y-2)+y/4-y/100+y/400)%7); } David Simpson
ebergman@isis.cs.du.edu (Eric Bergman-Terrell) (02/21/91)
The article "Date Management" in Computer Language's Dec. 90 issue has what you want. The program is in C but can be easily translated into Pascal (in fact I translated the code from Pascal to C to get it published). Terrell
abcscnuk@csunb.csun.edu (Naoto Kimura (ACM)) (02/21/91)
Boy, talk about frequently asked questions... You can also look in the Feb 1991 issue of Dr Dobb's Journal. The info you want is on page 148 in the "Structured Programming" column. The algorithm involved is called Zeller's Congruence. You might want to also take a look at the Oct 1990 and Nov 1990 issues for the actual code. //-n-\\ Naoto Kimura _____---=======---_____ (abcscnuk@csuna.csun.edu) ====____\ /.. ..\ /____==== // ---\__O__/--- \\ Enterprise... Surrender or we'll \_\ /_/ send back your *&^$% tribbles !!
andyross@ddsw1.MCS.COM (Andrew Rossmann) (02/24/91)
In article <1991Feb15.121713.10075@newcastle.ac.uk> Boye.Tranum@newcastle.ac.uk (B. Tranum) writes: >I need to find out the name of the day (Monday, Tuesday etc.) from the date >and the year. For example, which day was 10-02-91. - It was a Sunday. > >Does anybody have a nice routine, in Pascal or in English, to do this. I would >be very pleased if you could help me. There are two routines in Turbo Pascal (you didn't say what Pascal or version you wanted.) procedure GetDate(var year, month, day, dayofweek: word); procedure SetDate(year, month, day: word); Both are part of the DOS unit. For dayofweek, 0 = Sunday. If you want to find the dayofweek for any date, save the current date, set it to what you want, read it back to get the dow, and then reset it back. (The only problem might be if you run this right around midnight!!) Programming-wise, this is the easiest. It lets DOS do all the hard work. The only drawback is that it can't go back farther than 1-1-1980.