Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!ginosko!uunet!ncrlnk!wright!bkottman From: bkottman@wright.EDU (Brett Kottmann) Newsgroups: comp.lang.pascal Subject: Re: Day of Week Algorithm Message-ID: <676@thor.wright.EDU> Date: 25 Sep 89 19:05:11 GMT References: <6570@hubcap.clemson.edu> Organization: Wright State University, Dayton OH, 45435 Lines: 27 in article <6570@hubcap.clemson.edu>, bo@hubcap.clemson.edu (Bo Slaughter) says: > > > Does anyone out there have a day of the week algorithm in pascal? > I want to be able to pass to it the date, and get the day out. > Something like this: > > function dayofweek(day,month,year:integer):integer; > > Pass to it 09 as the month, 24 as the day, and 1989 as the year, and get > 1 as the output (sunday). > Turbo Pascal has one built in, otherwise, most of the Pascal textbooks use that program as an example. It is similar to: check_for_leap_year(date); (add 1 for jan if yes) day_of_week = (day_of_year mod 7) + 1; where day_of_year is from 1..365 (366 for leap year). you can convert to day or have a set of (mon, tue, etc.) and use the pos() function also.