9fans archive / 1999 / 01 / 10 / prev next
From: presotto@pla... presotto@pla...
Subject: [9fans] Some plan9 y2k problems
Date: Tue, 12 Jan 1999 15:42:42 -0500
In case anyone cares...
They all involve screw ups in figuring out leap years.
The ctime.c one is stupidly calls dysize with the year
minus 1900 instead of the year. Change it like the
following.
/sys/src/libc/9sys/ctime.c:
% diff /n/dump/1998/0513/sys/src/libc/9sys/ctime.c ctime.c
137c137
< for(d1 = 70; day >= dysize(d1); d1++)
---
> for(d1 = 1970; day >= dysize(d1); d1++)
140c140
< for (d1 = 70; day < 0; d1--)
---
> for (d1 = 1970; day < 0; d1--)
142c142
< xtime.year = d1;
---
> xtime.year = d1-1900;
/sys/src/cmd/ftpfs/tm2sec.c:
/sys/src/9/*/devrtc.c:
yrsize() computes the leap year incorrectly. It should look like:
static int *
yrsize(int y)
{
if((y%4) == 0 && ((y%100) != 0 || (y%400) == 0))
return ldmsize;
else
return dmsize;
}
There are probably other versions of this. I know I fixed it in
several places. Good luck.