home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
trn36-2.zip
/
leapyear.p
next >
Wrap
Internet Message Format
|
1996-01-11
|
2KB
From news.space.net!news.ecrc.de!news.sprintlink.net!nntp.coast.net!news.net99.net!news.crosslink.net!not-for-mail 8 Jan 1996 20:57:14 -0000
Path: news.space.net!news.ecrc.de!news.sprintlink.net!nntp.coast.net!news.net99.net!news.crosslink.net!not-for-mail
From: shields@crosslink.net (Michael Shields)
Newsgroups: comp.sources.bugs
Subject: Re: trn 3.6 leap year bug (unofficial patch)
Date: 8 Jan 1996 20:57:14 -0000
Organization: CrossLink Internet Access and Networking Services
Lines: 53
Message-ID: <4cs0fa$ui9@hermes.crosslink.net>
References: <4chi8v$6h5@solutions.solon.com>
NNTP-Posting-Host: hermes.crosslink.net
In article <4chi8v$6h5@solutions.solon.com>,
Peter Seebach <seebs@solutions.solon.com> wrote:
> ! /* This simple algorithm will be valid until the year 2099 */
Might as well plan for the long term.
Index: nntp.c
===================================================================
RCS file: /usr/local/src/master/trn/nntp.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 nntp.c
*** 1.1.1.1 1995/12/28 18:18:40
--- nntp.c 1996/01/08 20:50:49
***************
*** 306,320 ****
s[4] = '\0';
year = atoi(s);
! /* This simple algorithm will be valid until the year 2400 */
! if (year % 4)
maxdays[2] = 28;
! else
maxdays[2] = 29;
if (month < 1 || month > 12 || day < 1 || day > maxdays[month]
|| hh < 0 || hh > 23 || mm < 0 || mm > 59
|| ss < 0 || ss > 59)
return time((time_t*)NULL);
for (month--; month; month--)
day += maxdays[month];
--- 306,325 ----
s[4] = '\0';
year = atoi(s);
! maxdays[2] = 28;
! if (year % 4 == 0)
! maxdays[2] = 29;
! if (year % 100 == 0)
maxdays[2] = 28;
! if (year % 400 == 0)
maxdays[2] = 29;
if (month < 1 || month > 12 || day < 1 || day > maxdays[month]
|| hh < 0 || hh > 23 || mm < 0 || mm > 59
|| ss < 0 || ss > 59)
return time((time_t*)NULL);
+
+ if (maxdays[2] == 29 && month < 3)
+ --day; /* kluge to allow for the below */
for (month--; month; month--)
day += maxdays[month];
--
Shields, CrossLink.