Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!batcomputer!rpi!pawl4.pawl.rpi.edu!mketch From: mketch@pawl.rpi.edu (Michael D. Ketchen) Newsgroups: comp.lang.pascal Subject: Re: Day-of-week algorithm, please! Summary: It's the latter... Keywords: day of the week Message-ID: <1265@rpi.edu> Date: 13 Apr 89 18:14:58 GMT References: <19040@adm.BRL.MIL> <1780001@hpcc01.HP.COM> <2394@maccs.McMaster.CA> Sender: usenet@rpi.edu Organization: Rensselaer Polytechnic Institute, Troy, NY Lines: 37 In article <2394@maccs.McMaster.CA> cs3b3aj@maccs.UUCP (Stephen M. Dunn) writes: >In article <1780001@hpcc01.HP.COM> azarian@hpcc01.HP.COM (Randy Azarian) writes: >... >> total := total + + (year - 1) div 4; > > But watch out, because not every year such that year mod 4 = 0 is a leap >year! The strangeness in the pattern occurs on century years, but I'm not >sure which way round it is. It is either that years divisible by 400 are >_not_ leap years, or that any century year is not a leap year _except_ >for years divisible by 400. > (etc. etc.) > Does anyone know which way it is? ... >! Stephen M. Dunn, cs3b3aj@maccs.McMaster.CA Every fourth year is a leap year (1988, 1992, etc.), unless it falls on the end of a century (1800, 1900, etc), in which case it's not a leap year, _unless_ it's a multiple of 400 (2000, 2400, etc.), in which case it _is_ a leap year. Confusing, eh? The following function should return TRUE if the year passed is leap. function IsALeap (year: integer): boolean; (* returns TRUE if 'year' is a leap year *) begin IsALeap:=FALSE; if ((year mod 4)=0) and ((year mod 100)<>0) or ((year mod 400)=0) then IsALeap:=TRUE end; (* IsALeap *) Hope this helps... - Mike -------------------------------------------------------------------------------- mketch@pawl.rpi.edu (Internet) | Mike (Dave) Ketchen | "Yes, Santa Claus, there ketchenm@rpitsmts (Bitnet) | Overworked Student | is a Virginia..." --------------------------"I say, anyone for tennis?"---------------------------