[tz] Are these valid timezone definitions?

Zefram zefram at fysh.org
Thu Jun 14 16:29:16 UTC 2012


Tadashi Abe wrote:
>Why doesn't it work well when I try to test by modifying the actual
>system clock?

Presumably you're not setting the clock to the time you think you are.
The time you give is being interpreted according to the timezone
nominated by $TZ (the $TZ prevailing for the process that sets the clock,
of course).  Any local time in the hour before DST ends is ambiguous,
because the clocks going back causes the same local times to occur again.
You don't get to control which instance of that local time you actually
get.

The best way to check what time the system clock is actually set to is
to display it in UTC, which you can do with "TZ=UTC date" or "date -u".
Likewise, the best way to set the system clock to a particular time is
to specify the target time in UTC, which you can do with "TZ=UTC date
061416242012.55" or "date -u 061416242012.55".  In this sort of context,
you should only use a non-UTC timezone only to produce the output that
you're testing.

Apart from this, setting the system clock is a bad test methodology
because, er, it sets the system clock.  date's -d option is there so that
you don't have to disrupt the whole system just to feed a non-current
timestamp into date's display logic.  The logic is the same either way:
if the output is right with -d, you can be sure it'll also be right when
that timestamp is actually read from the system clock.

-zefram


More information about the tz mailing list