Date: Mon, 17 Aug 1998 15:30:28 +0000 From: "Kaleb S. KEITHLEY" <kaleb@ics.com> To: hackers@FreeBSD.ORG Subject: WRT y2k compliance, in 2000, the day after Feb 28 is NOT Feb 29. Message-ID: <35D84C94.635DDD5E@ics.com>
next in thread | raw e-mail | index | archive | help
All this talk about y2k stuff, consider the following:
#include <sys/types.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main ()
{
time_t feb28; /* 28 Feb, 2000, 23:59:59 */
time_t mar1;
struct tm tm_feb28; /* 28 Feb, 2000, 23:59:59 */
struct tm* tm_mar1; /* 1 Mar, 2000, 00:00:00 */
tm_feb28.tm_sec = tm_feb28.tm_min = 59;
tm_feb28.tm_hour = 23;
tm_feb28.tm_mday = 28;
tm_feb28.tm_mon = 1;
tm_feb28.tm_year = 100;
tm_feb28.tm_isdst = -1; /* for POSIX mktime to DTRT WRT DST */
feb28 = mktime (&tm_feb28);
(void) printf ("%s\n", ctime (&feb28));
mar1 = feb28 + 1;
(void) printf ("%s\n", ctime (&mar1));
tm_mar1 = gmtime (&mar1);
(void) printf ("month (s/b 2):%d\n", tm_mar1->tm_mon);
(void) printf (" day (s/b 1):%d\n", tm_mar1->tm_mday);
return 0;
}
I ran this program on:
SunOS 4.1.4,
Solaris 2.5.1
Solaris 2.6
HPUX 10.20
IRIX 5.3
IRIX 6.2
Digital Unix 3.2
Redhat Linux 5.0 (libc6/glibc 2.0.7)
and they all got it wrong. (It could be that one or more of them are
fixed in some patch I don't have installed. <shrug>) I didn't try on
FreeBSD because that's at home, but I'd be willing to wager serious
money that it gets it wrong too.
And I didn't check, but if they all think 2000 has a 29 Feb., then I'd
wager they think that there's 366 days in the year too, and that all the
day-of-the-week are off by a day for every day after Feb 28.
/usr/bin/cal is broken too on the two systems I checked.
--
Kaleb S. KEITHLEY
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?35D84C94.635DDD5E>
