*BSD News Article 10481


Return to BSD News archive

Received: by minnie.vk1xwt.ampr.org with NNTP
	id AA188 ; Fri, 29 Jan 93 07:00:29 EST
Newsgroups: comp.unix.bsd
Path: sserve!manuel.anu.edu.au!munnari.oz.au!spool.mu.edu!yale.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!sunic!seunet!dynas!micke
From: micke@dynas.se (Mikael Hybsch)
Subject: Re: [386bsd] New patch00071 is slightly wrong
Message-ID: <1993Jan28.160239.16048@dynas.se>
Sender: news@dynas.se (News Administrator)
Organization: DynaSoft, Dynamic Software AB
References: <bIQKePhq40@astral.msk.su>
Date: Thu, 28 Jan 1993 16:02:39 GMT
Lines: 29

In <bIQKePhq40@astral.msk.su> "Andrew A. Chernov, Black Mage" <ache@astral.msk.su> writes:

>I just look into new patch00071 of clock.c and found small bug,
>it don't calculate leap year properly, produce error in 2000 year.

The rule "year % 4" will work until year 2100, because (2000 % 400) is 0.
Of course we still want our grand children to be able o use the correct time
when they play with 386bsd.

>! 	if (sec < 1970)
>! 		sec += 100;
>! 	leap = !(sec % 4); sec = ytos(sec); /* year    */

>Correct way to calculate leap year is:

>#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0)

>see for example /usr/include/tzfile.h
>-- 
>In-This-Life:  Andrew A. Chernov    |  "Hay mas dicha, mas contento
>Internet:      ache@astral.msk.su   |  "Que adorar una hermosura
>FIDOnet:       2:5020/23.34         |  "Brujuleada entre los lejos
>Organization:  The RELCOM Corp.     |  "De lo imposible?!"  (Calderon)

-- 
 Mikael Hybsch                        Email: micke@dynas.se
 DynaSoft, Dynamic Software AB        Phone: +46-8-615 84 00
 Hammarby Fabriksv 13, Box 92058      Fax:   +46-8-641 92 00
 S-120 06 STOCKHOLM, SWEDEN