Overview
| Artifact ID: | 9c0bea9e78c66a32811f1a442310dc30ab9aa54d |
|---|---|
| Ticket: | 218769ffffffffffffffffffffffffffffffffff
incorrect leap year handling in generic/tclDate.c |
| User & Date: | nobody on 2000-10-26 01:05:09 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
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 - foundin changed to: "obsolete: 8.1"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "69. Other"
- title changed to: "incorrect leap year handling in generic/tclDate.c"
- type changed to: "Bug"