|
2001-04-18
| ||
| 07:08 | • Ticket [218769ffff] incorrect leap year handling in generic/tclDate.c status... artifact: 8a94ac2414 user: dgp | |
|
2000-10-26
| ||
| 08:28 | • Closed ticket [218769ffff]. artifact: 3041ce4ca3 user: welch | |
| 01:05 | • New ticket [218769ffff]. artifact: 9c0bea9e78 user: nobody | |
incorrect leap year handling in generic/tclDate.c
Closed / Fixed218769ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:05:09
OriginalBugID: 2066 Bug
Version: 8.1
SubmitDate: '1999-05-14'
LastModified: '1999-07-01'
Severity: MED
Status: Released
Submitter: pat
ChangedBy: foster
OS: Solaris
Machine: Other
FixedDate: '1999-05-19'
FixedInVersion: 8.2b1
ClosedDate: '2000-10-25'
Name: Isaac Hollander
Comments:
This is a crucial Y2K issue. Scriptics's Y2K statement discusses the 2
digit year issue in great details, but does not address proper leap year
handling.
ReproducibleScript:
This is already reported as bugID 1985, but I can't figure out how to
update an existing bug. Please close out bugID 1985 and use this bug
report.
The leap year handling in the Convert() routine in generic/tclDate.c is
incorrect. Leap years are divisible by 4, unless it's divisible by 100,
in which case it's a leap year only if it's divisible by 400. Hence
2000 is a leap year, but 2100 is not.
The code is incorrect in all versions of tcl I've looked at from 8.0p2
through the latest code in CVS.
Patch:
$ diff -c tclDate.c tclDate.c.orig
*** tclDate.c Thu May 6 17:32:51 1999
--- tclDate.c.orig Mon Feb 10 13:03:15 1997
***************
*** 430,439 ****
Julian += DaysInMonth[i];
if (Year >= EPOCH) {
for (i = EPOCH; i < Year; i++)
! Julian += 365 + ( (i % 4 == 0) && ((i % 100 != 0) || (i % 400 == 0
)) );
} else {
for (i = Year; i < EPOCH; i++)
! Julian -= 365 + ( (i % 4 == 0) && ((i % 100 != 0) || (i % 400 == 0
)) );
}
Julian *= SECSPERDAY;
Julian += TclDateTimezone * 60L;
--- 430,439 ----
Julian += DaysInMonth[i];
if (Year >= EPOCH) {
for (i = EPOCH; i < Year; i++)
! Julian += 365 + (i % 4 == 0);
} else {
for (i = Year; i < EPOCH; i++)
! Julian -= 365 + (i % 4 == 0);
}
Julian *= SECSPERDAY;
Julian += TclDateTimezone * 60L;
$
PatchFiles:
generic/tclDate.c
This patch is good and needs to be applied. However, to avoid any confusion
this is not a Y2K issue. Things will work fine for dates around 2000. In fact,
the nearest dates this will be a problem are 1900 and 2100 (which are not
even in the UNIX epoch!). None the less, this is a bug and should be fixed.
05/14/1999 10:00 - rjohnson -
Applied the patch. It's probably not going to be an issue, but it won't hurt to
play it a little safer. 05/14/1999 10:30 - redman -
-- 05/17/1999 hershey
welch Closed ticket [218769ffff].
[History diff]2000-10-26 08:28:14
dgp Ticket [218769ffff]: 3 changes
[History diff]2001-04-18 07:08:41
Log in (anonymous is fine) to add a comment.