*BSD News Article 10475


Return to BSD News archive

Received: by minnie.vk1xwt.ampr.org with NNTP
	id AA181 ; Fri, 29 Jan 93 05:02:11 EST
Path: sserve!manuel.anu.edu.au!munnari.oz.au!spool.mu.edu!darwin.sura.net!newsserver.jvnc.net!gmd.de!Germany.EU.net!mcsun!news.funet.fi!fuug!kiae!newsserv
From: "Andrew A. Chernov, Black Mage" <ache@astral.msk.su>
Newsgroups: comp.unix.bsd
Subject: [386bsd] New patch00071 is slightly wrong
Date: Wed, 27 Jan 93 15:50:34 +0300
Distribution: world
Organization: Ha-oh-lahm Yetzirah
Message-ID: <bIQKePhq40@astral.msk.su>
Sender: news-service@newcom.kiae.su
Reply-To: ache@astral.msk.su
Lines: 18

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.

! 	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)