Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Apr 2007 07:27:10 -0600 (MDT)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        grog@freebsd.org
Cc:        cvs-src@freebsd.org, src-committers@freebsd.org, brian@freebsd.org, cvs-all@freebsd.org
Subject:   Re: cvs commit: src/usr.bin/touch touch.1 touch.c
Message-ID:  <20070410.072710.1678773672.imp@bsdimp.com>
In-Reply-To: <20070410050011.GH91694@wantadilla.lemis.com>
References:  <20070410010510.GB61460@wantadilla.lemis.com> <20070409.222011.1689682576.imp@bsdimp.com> <20070410050011.GH91694@wantadilla.lemis.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In message: <20070410050011.GH91694@wantadilla.lemis.com>
            "Greg 'groggy' Lehey" <grog@FreeBSD.org> writes:
: On Monday,  9 April 2007 at 22:20:11 -0600, M. Warner Losh wrote:
: > In message: <20070410010510.GB61460@wantadilla.lemis.com>
: >             "Greg 'groggy' Lehey" <grog@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
arbitrary epoch.

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
type.

: > 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.

Warner



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070410.072710.1678773672.imp>