[rb-general] TZ=UTC wrong?

Colin Watson cjwatson at debian.org
Wed Oct 30 13:09:33 UTC 2019


On Wed, Oct 30, 2019 at 12:42:54PM +0000, Holger Levsen wrote:
> On Tue, Oct 29, 2019 at 09:00:15PM +0200, Niko Tyni wrote:
> > On Mon, Oct 28, 2019 at 12:28:32PM +0100, Guillem Jover wrote:
> > > Just noticed this change from the changelog. :) UTC is not really a
> > > proper timezone specification, the format requires an offset, so here
> > > it would be UTC0 (see «man timezone»).
> > Oh! Thanks for the note. This is probably a very common misconception.
> > I think the reproducible builds docs have advised setting TZ=UTC in
> > the past, and I see https://reproducible-builds.org/docs/timezones/
> > mentions it currently.
> > Also, codesearch.debian.net reports 95 packages matching TZ=UTC
> > but only two match TZ=UTC[0-9]. Time for a mass bug filing? :)
> 
> I'd like to defer this question to debian-devel at . OTOH UTC0 indeed seems
> to be technically correct (eg indicated by https://en.wikipedia.org/wiki/UTC
> 's disambiguation notice stating 'This article is about the time standard
> abbreviated as "UTC". For the time offset between UTC−1 and UTC+1, see
> UTC±00:00.' though of course this is not the proper definition which is
> $somewhere_else_), on the other hand TZ=UTC is something not surely me
> has learned, used and taught many many times but many many many other people
> as well.

First, is this a distinction with a meaningful difference worth spending
the time on changing it?

Second, it is not correct to say that the format requires an offset.
Referring to timezone(3), the format being used is not the first one
("std offset[dst[offset][,start[/time],end[/time]]]", which I'll call
the "systematic format" below), but the second:

       The second format specifies that the timezone information should
       be read from a file:

           :[filespec]

       If the file specification filespec is omitted, or its value
       cannot be interpreted, then Coordinated Universal Time (UTC) is
       used.  If filespec is given, it specifies another
       tzfile(5)-format file to read the timezone information from.  If
       filespec does not begin with a '/', the file specification is
       relative to the system timezone directory.  If the colon is
       omitted each of the above TZ formats will be tried.

This documentation is IMO poorly drafted, but if you read all of it
rather than just the pseudo-grammar, it's clear that the colon may in
fact be omitted, and in this case it therefore refers to a file name
relative to the system timezone directory, namely
/usr/share/zoneinfo/UTC.  Perfectly fine.

The only practical difference I see is that, for TZ=UTC0, the libc might
in theory decide to compute the timezone without reference to
/usr/share/zoneinfo/ at all.  Except that isn't actually what strace
shows it does: it tries to open /usr/share/zoneinfo/UTC0, gets ENOENT,
and then computes the timezone using the systematic format.  So it isn't
even likely to make any performance difference worth mentioning.

Since TZ=UTC is technically correct per timezone(3), I'd stick with it
unless there's a demonstrable practical difference (perhaps
compatibility on some odd systems?) justifying the effort involved in
changing it.

-- 
Colin Watson                                       [cjwatson at debian.org]


More information about the rb-general mailing list