From mboxrd@z Thu Jan 1 00:00:00 1970 Message-Id: <200301182303.h0IN3cw09176@augusta.math.psu.edu> To: 9fans@cse.psu.edu From: Dan Cross Subject: [9fans] Fix to tm2sec(). Date: Sat, 18 Jan 2003 18:03:38 -0500 Topicbox-Message-UUID: 43521d9c-eacb-11e9-9e20-41e7f4b1d025 I fixed a bug in tm2sec() where it didn't take into account tm->yday. Now, if tm->yday is nonzero, it uses that instead of accumulating seconds based on month and day in month. A patch in diff -e format follows. btw- The handling of tm->year seems suboptimal to me; shouldn't this be the 4 digit year, instead of the current year - 1900? I realize that on Unix, (struct tm *)->tm_year is years since 1900, but this isn't Unix, and it just strikes me as goofy. - Dan C. term% diff -e /n/sources/plan9/sys/src/libc/9sys/tm2sec.c tm2sec.c 76,79c /* * secs in last month */ secs += (tm->mday-1) * SEC2DAY; } . 69,74c if (tm->yday != 0) secs += (tm->yday - 1) * SEC2DAY; else { /* * seconds per month */ d2m = yrsize(year); for(i = 0; i < tm->mon; i++) secs += d2m[i+1] * SEC2DAY; . term% pwd /sys/src/libc/9sys term%