From: | Andrew Bell |
Date: | 31 Dec 99 at 14:03:01 |
Subject: | Check your sources for Y2K bugs! |
From: Andrew Bell <andrew.ab2000@bigfoot.com>
Hi all,
I've been doing some checks with Hisoft C++ (which is based on the
Maxon C++ compiler) and have noticed that the Maxon ANSI link lib is
not Y2K compliant. The function at fault is strftime() (and possibly
a few others too).
If you have the Hisoft C++/Maxon C++ compilers and run the following
code (make sure your clock is set to the year 2000), you'll see that
the year digits are always wrong.
----------------------------------
#include <stdio.h>
#include <time.h>
int main( void )
{
unsigned char buf[256];
time_t now = time(NULL);
struct tm *tmnow = localtime(&now);
if (strftime(buf, 256,
"Y = '%Y' (complete year, including the century)\n"
"y = '%y' (year without the century)\n"
"x = '%x' (shorthand date)\n"
"c = '%c' (shorthand date and time)\n" , tmnow) == 0)
printf("Call to strftime() failed!\n")
else
printf(buf);
return 0;
}
-------------------------
The results are the same every time I run this code. The only solution
I can see is to avoid linking in strftime() and use some alternative
date routines or fix/patch your lib. So if you're using Hisoft
C++/Maxon C++, check your sources and spread the word!
Since link libs are static, this means that any Maxon compiled
programs out there that use strftime() will fail when constructing
their year strings. The extent and seriousness of the failures will
be unknown until the programs are tested in the year 2000.
Regards, Andrew Bell.
+----------------------------------------+
email: mailto:andrew.ab2000@bigfoot.com or
mailto:andrew@ab2000.prestel.co.uk
web: http://www2.prestel.co.uk/ab2000
+----------------------------------------+
Bring the whole family...but leave the kids at home.