negative time_t values

Moderator, John Quarterman std-unix at ut-sally.UUCP
Tue Sep 16 00:57:00 AEST 1986


From: cbosgd!cbosgd.ATT.COM!mark at seismo.UUCP (Mark Horton)
Date: Wed, 10 Sep 86 12:40:40 edt
Organization: AT&T Bell Laboratories, Columbus

There are many uses for dates, on which you'd like to be able
to do arithmetic.  I don't see where the assumption that time_t
is only useful for file modification times got made.  We have
an application that needs to be able to store birth dates of
people living today, and of their parents.  We would like to be
able to use the same format for parents' birth dates and for
machine generated time stamps.  And we'd like to be able to
easily add or subtract 3 hours, for example, from such a quantity.

Note that all the UNIX routines to deal with dates, such as ctime,
localtime, gmtime, and asctime, deal with time_t quantities.  There
are no operations provided to manipulate a struct tm.  This means
there's a huge penalty for any application that needs to manipulate
times that might be before 1970 or after 2038.  They must implement
a set of primitives to manipulate a struct tm or other data structure
(such as an ISO format time string, which is also broken into year,
month, day, etc.)

Even if you offered us dates back to 1901, it wouldn't be enough for
our application.  We have to go back to about 1850.  But I would hope
to see some facilities added to manipulate a more general date/time
format than a time_t.  Maybe the 4.2BSD struct timeval needs to have
another field added to indicate a base year (defaulting to 1970.)

	Mark

[ There are manipulation (adding, subtracting) routines for timeval
in the 4.2BSD kernel, by the way, though they never seem to have been
brought out into a user-accessible library, even in 4.3BSD (except
for timerisset, timercmp, and timerclear in <sys/time.h>).  -mod ]

Volume-Number: Volume 6, Number 47



More information about the Mod.std.unix mailing list