On Wed, Jan 12, 2000 at 09:28:11AM +0000, Edmund GRIMLEY EVANS wrote:
> John Franklin <[EMAIL PROTECTED]>:
> 
> > At least on my system, time_t is signed.  Sometime in January 2038 it 
> > flips back to sometime in January 1901.  I think that's the common
> > implementation.
> 
> I assume you mean December 1901.
> 
> I've heard about this signed implementation, but never seen it in
> practice. Is it really that common? Most programs seem to treat
> negative values of time_t as invalid.
> 
> By the way, Europeans who want to celebrate the end of the 31-bit era
> will have to stay up late. The last valid date is "Tue, 19 Jan 2038
> 03:14:07 +0000".

I get the same output below on both a Red Hat 5.1 system and a NetBSD 1.3.3
system.  ISTR getting the same on a FreeBSD 2.x.x system some time ago,
too.  Under Windows NT, the second gmtime() call returns NULL.

"Is it common?" is left as an exercise to the reader.  :)

[9]% more foo.c
#include <stdio.h>
#include <time.h>

int main()
{
struct tm *tm;
time_t t;

t = 0x7fffffff;
tm=gmtime(&t);
printf("%s\n",asctime(tm));
t = 0x80000000;
tm=gmtime(&t);
printf("%s",asctime(tm));
}
[10]% ./foo
Tue Jan 19 03:14:07 2038

Fri Dec 13 20:45:52 1901
[11]%

jf
-- 
John Franklin
[EMAIL PROTECTED]
ICBM: N37 12'54", W80 27'14" Z+2100'

Reply via email to