🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9564

Re: calculating leap years

#9564
From: fgd3
Date: Wed, 15 Oct 1986 03:38
35 lines
2057 bytes
In article <813@ethos.UUCP>, ggw@ethos.UUCP (Gregory Woodbury) writes:
> In at least one industrial control system, there is going to be a discrepancy
> between the VAXen and their comm controllers.  I had modified the comm system
> date routines to handle the 2000 non-leap year...
> ------------------------------------------
> Gregory G. Woodbury				The usual disclaimers apply
> Red Wolfe Software and Services, Durham, NC
> {duke|mcnc|rti-sel}!ethos!ggw

     Let's get this straight.  The year 2000 will be a leap year.  The
years 1900 and 2100 are not leap years.  The rule is a year is a leap year
if it is evenly divisible by 4 and is not divisible by 100 EXCEPT FOR THOSE
CENTURY YEARS WHICH ARE DIVISIBLE BY 400.

     One of the reasons it is important to write date handling functions
correctly is there aren't enough people who understand the rule.  Let's
give them a correct function and let them copy it.  There is a very
readable date conversion function in K&R, first discussed on pages 103-105,
then again on pages 119-120.  The part that determines whether a year is a
leap year is

{
     int leap, year;
     leap = year%4 == 0 && year%100 !=0 || year%400 == 0;
}

     I hope that will save someone from getting bitten by a wrong
calculation.

Fabbian Dufoe
  350 Ling-A-Mor Terrace South
  St. Petersburg, Florida  33705
  813-823-2350

UUCP: ...akgua!akguc!codas!peora!ucf-cs!usfvax2!jc3b21!fgd3 
Technical Details
Message-ID: <484@jc3b21.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!rutgers!nike!ucbcad!ucbvax!decvax!decwrl!amdcad!amd!pesnta!peora!ucf-cs!usfvax2!jc3b21!fgd3
References: <40@vianet.UUCP> <813@ethos.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!rutgers!nike!ucbcad!ucbvax!decvax!decwrl!amdcad!amd!pesnta!peora!ucf-cs!usfvax2!jc3b21!fgd3
From: fgd3@jc3b21.UUCP
Newsgroups: net.lang.c
Subject: Re: calculating leap years
Message-ID: <484@jc3b21.UUCP>
Date: Tue, 14-Oct-86 23:38:29 EDT
Article-I.D.: jc3b21.484
Posted: Tue Oct 14 23:38:29 1986
Date-Received: Wed, 15-Oct-86 21:55:59 EDT
References: <40@vianet.UUCP> <813@ethos.UUCP>
Distribution: net
Organization: St. Petersburg Jr. College, St. Petersburg FL
Lines: 35
Summary: 2000 is a leap year.