Subject: signed vs unsigned time_t
To: Tim Rightnour <root@garbled.net>
From: Robert Elz <kre@munnari.OZ.AU>
List: tech-userlevel
Date: 06/04/1998 08:26:34
    Date:        Wed, 03 Jun 1998 04:55:13 -0700 (MST)
    From:        Tim Rightnour <root@garbled.net>
    Message-ID:  <XFMail.980603050056.root@garbled.net>

  | I've never understood the logic of having made that a signed integer.  Was
  | there ever a point where it was imagined unix boxes would power time
  | machines?

I made time_t unsigned, and dumped that into the Berkeley sources
sometime around the 4.2bsd timeframe.   With just a few assorted
changes other places, it worked just fine for me.

It didn't last at Berkeley though, too many people who have the misfortune
to live west of Greenwich expected

	time_t t = 0;
	printf("%s", ctime(&t));

to print some time on Dec 31, 1969, and were not amused when the result was
of the order of 2107 or something instead ...

This is caused by simply subtracting the timezone offset (in unix west is
positive format) from the time, and then converting as if it were gmt -
subtract 300 from 0 in an unsigned variable and you get something big...

There are, of course, ways to fix that, but no-one was really confident
enough that similar things weren't being done elsewhere that might not be
so easily found, and so time_t went back to being signed again (my memory
is hopeless, but I think it remained unsigned less than a month).

kre