Path: utzoo!yunexus!maccs!cs3b3aj From: cs3b3aj@maccs.McMaster.CA (Stephen M. Dunn) Newsgroups: comp.lang.pascal Subject: Re: Day-of-week algorithm, please! Summary: Some years such that x mod 4 = 0 aren't leaps Message-ID: <2394@maccs.McMaster.CA> Date: 11 Apr 89 05:17:39 GMT Article-I.D.: maccs.2394 References: <19040@adm.BRL.MIL> <1780001@hpcc01.HP.COM> Reply-To: cs3b3aj@maccs.UUCP (Stephen M. Dunn) Organization: McMaster U., Hamilton, Ont., Can. Lines: 27 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. Confused? It's either that 1900, 2100, 2200, 2300, 2500 are leap years and 2000,2400 aren't (first case, above), or that 2000, 2400 are leap years and 1900, 2100, 2200, 2300, 2500 aren't. However, I'm not sure which way it is. If it's the first way, your function will only work for another 10 years or so. If it's the second way, your program's fine for another 110 years. Does anyone know which way it is? (Just to satisfy that part of my brain that killed the cat) If I were at home, I could look it up in a book on my bookshelf, but I'm here at school, so I'm in the dark. -- ====================================================================== ! Stephen M. Dunn, cs3b3aj@maccs.McMaster.CA ! DISCLAIMER: ! ! This space left unintentionally blank - vi ! I'm only an undergrad ! ======================================================================