cvs commit: src/usr.bin/touch touch.1 touch.c
M. Warner Losh
imp at bsdimp.com
Tue Apr 10 13:28:12 UTC 2007
In message: <20070410050011.GH91694 at wantadilla.lemis.com>
"Greg 'groggy' Lehey" <grog at FreeBSD.org> writes:
: On Monday, 9 April 2007 at 22:20:11 -0600, M. Warner Losh wrote:
: > In message: <20070410010510.GB61460 at wantadilla.lemis.com>
: > "Greg 'groggy' Lehey" <grog at freebsd.org> writes:
: >> On Monday, 9 April 2007 at 2:48:26 -0700, Brian Somers wrote:
: >>> I don't understand what this means. File times are in UTC aren't
: >>> they?
: >> No, they're in time_t. But if you import files from other systems,
: >> you frequently get times which are off by some time zone offset.
: > time_t is UTC, by definition (sadly, POSIX has enshrined a broken
: > definition of UTC as the time_t definition, but that's not important
: > right now).
: The definition of time_t is simply a number of seconds since a
: specified event. It's true that this event was the turn of the
: year/decade in UTC, but that doesn't make it UTC. Currently my time_t
: is 1176181168; that's not directly recognizable as any time zone.
You are incorrect. POSIX defines time_t as UTC. Full stop. It is
the definition of time_t. It defines it in a way that's broken for
leap seconds, so it isn't just an interval of seconds since some
time_t is also, confusingly, used in some places to specify a interval
in things like select. However, this is an abuse of a convenient
: > It cannot be a localtime. Localtime conversion of time_t is done by
: > libc to print the local time.
: But libc also needs to convert time_t to UTC.
No. Libc assumes time_t is UTC. See for example gmtime and
localtime. These take the same argument, but one returns the UTC time
(eg, the argument unbiased by localtime broken down into year, hour,
month, etc), while the other one returns the localtime (the argument,
biased by localtime and then broken down).
Even when one sets one CMOS clock to localtime, and maintains it by
adjkerntz and friends, the system clock is still in UTC.
More information about the cvs-src