🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Andrew A. Chernov, Black Mage Wed, 27 Jan 1993 12:50
[386bsd] New patch00071 is slightly wrong
#5794
Author: Andrew A. Chernov, Black Mage
Date: Wed, 27 Jan 1993 12:50
17 lines
1169 bytes
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)
Re: [386bsd] New patch00071 is slightly wrong
#5796
Author: Mikael Hybsch
Date: Thu, 28 Jan 1993 16:02
29 lines
1730 bytes
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads