Thread View: comp.bugs.misc
1 messages
1 total messages
Started by Jacob Gore
Thu, 05 Jan 1989 05:37
patch to calentool (bug showed up in 1989)
Author: Jacob Gore
Date: Thu, 05 Jan 1989 05:37
Date: Thu, 05 Jan 1989 05:37
59 lines
2441 bytes
2441 bytes
There is a bug in calentool that showed up when 1989 rolled around. The
symptom is that it believes that today is yesterday.
The fundamental problem is in array year_days in utils.c. The key is that
each location stores the number of days between the beginning of 1985 and
the BEGINNING of the year, not its end. Thus, the fact that 1988 is a leap
year adds 1 to 1989's location, not to 1988 (in the beginning of 1988, the
leap year has not taken toll yet).
This, of course, should have made it NOT work in 1988, because in 1988 an
extra day is added, and work again in 1989, because in 1989 one day too few
is added, making it in step again. My feeling is that it didn't work in
1988, and that's why there is a "- 1" in the computation, to compensate for
the bug. The "- 1" screws things up in 1989, however.
The following patch fixes that data in the array, and removes the "- 1",
which I very strongly suspect to be a kluge.
Jacob Gore Gore@EECS.NWU.Edu
Northwestern Univ., EECS Dept. {oddjob,gargoyle,att}!nucsrl!gore
*** /tmp/,RCSt1005087 Wed Jan 4 23:17:51 1989
--- utils.c Wed Jan 4 23:02:30 1989
***************
*** 90,97 ****
/* cummulative number of days since Jan 1, 1985 by years to 1999 */
/* (takes into account leap years in 1988, 1992, 1996) */
! int year_days[] = {0, 365, 730, 1096, 1461, 1826, 2191, 2557, 2922,
! 3287, 3652, 4018, 4383, 4748, 5113};
get_today()
{
--- 90,97 ----
/* cummulative number of days since Jan 1, 1985 by years to 1999 */
/* (takes into account leap years in 1988, 1992, 1996) */
! int year_days[] = {0, 365, 730, 1095, 1461, 1826, 2191, 2556, 2922,
! 3287, 3652, 4017, 4383, 4748, 5113};
get_today()
{
***************
*** 101,107 ****
gettimeofday(&tv, 0);
tm = localtime(&tv.tv_sec);
! t = tm->tm_yday + year_days[tm->tm_year-85] - year_days[START_YEAR-85] - 1;
return(t);
}
--- 101,107 ----
gettimeofday(&tv, 0);
tm = localtime(&tv.tv_sec);
! t = tm->tm_yday + year_days[tm->tm_year-85] - year_days[START_YEAR-85];
return(t);
}
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