🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9322

Re: Calendar Functions (simpler leap year calculation)

#9322
From: Daniel R. Levy
Date: Tue, 16 Sep 1986 23:34
35 lines
2005 bytes
In article <34@vianet.UUCP>, devine@vianet.UUCP (Bob Devine) writes:
>Dave Lewis writes:
>> leapyear (year)
>> int year;
>> {
>>   if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
>>      return (1);
>>   else
>>      return (0);
>> }
>
>  While this works, it is overkill.  Unless you believe that your
>code will make it to the year 2100, a simple test for divisibility
>by 4 is sufficient.  If you really want an algorithm for all years,
>you then need to also test for years divisible by 4000...
>
...
>
>#define  isleapyear(year)   ((year)%4)
>
>Bob Devine

Butbutbut... whattabout code which deals with things that are of concern
over more than a few years' scope, such as positions of the heavenly bodies?
The code needn't last till the year 2100 to want to deal with things that
are going to happen then (only the printouts :-) ).  And what about birth
dates of very old people?
-- 
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
	   go for it!  			allegra,ulysses,vax135}!ttrdc!levy
Technical Details
Message-ID: <1193@ttrdc.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!lll-lcc!qantel!ihnp4!cuae2!ltuxa!ttrdc!levy
References: <206@cascade.STANFORD.EDU> <1229@loral.UUCP> <34@vianet.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!lll-lcc!qantel!ihnp4!cuae2!ltuxa!ttrdc!levy
From: levy@ttrdc.UUCP (Daniel R. Levy)
Newsgroups: net.lang.c
Subject: Re: Calendar Functions (simpler leap year calculation)
Message-ID: <1193@ttrdc.UUCP>
Date: Tue, 16-Sep-86 19:34:50 EDT
Article-I.D.: ttrdc.1193
Posted: Tue Sep 16 19:34:50 1986
Date-Received: Wed, 17-Sep-86 08:16:33 EDT
References: <206@cascade.STANFORD.EDU> <1229@loral.UUCP> <34@vianet.UUCP>
Distribution: net.lang.c
Organization: AT&T, Computer Systems Division, Skokie, IL
Lines: 35