*BSD News Article 24787


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!constellation!paladin.american.edu!europa.eng.gtefsd.com!uunet!zib-berlin.de!irz401!uriah!not-for-mail
From: j@uriah.sax.de (J Wunsch)
Newsgroups: comp.os.386bsd.questions
Subject: Re: TimeZone question.
Date: 7 Dec 1993 18:55:21 +0100
Organization: Private U**X site; member IN e.V.
Lines: 47
Message-ID: <2e2g29INNb7q@bonnie.sax.de>
References: <2c9n3o$ola@terminator.rs.itd.umich.edu> <CGnu19.7E@luva.stgt.sub.org>
NNTP-Posting-Host: bonnie.sax.de

In <CGnu19.7E@luva.stgt.sub.org>
migieger@luva.stgt.sub.org (Michael Giegerich) writes:

>Leave your kernel at GMT (``timezone 0'') and use
>TZ=<your timezone><offset from GMT> w/ your shell
>(e.g. in middle Europe: TZ=MET-1).

>This approach has the advantage that you havn`t to
>recompile the kernel when changing timezone - and
>the disadvantage that you need a shell which supports
>the TZ env variable (like bash or tcsh, don't know
>for others).

This approach has the disadvantage of not taking care for DST change-
overs. You've just hard-coded the timezone offset to 60 minutes, ugly.
Wrong: your shell does not deal at all with TZ, except it's maintaining
the environment for sub-processes. The ctime(3) functions will care for
it, thus there is no impact from the shell.

Furthermore, *BSD has a posixized timezone handling mechanism. It knows
best about your local DST behaviour and timezone offsets. It is necessary
to symlink the appropriate file to /etc/localtime. For middle-european
time, this is /usr/share/zoneinfo/MET. U.S. zones are found under /usr/
share/zoneinfo/US. This symlink indicates what's the default timezone
(just the zone where the machine is physically located). It can be over-
ridden by any TZ variable. The old style TZ (with an explicit timezone
offset) is still supported. But much better were to use a POSIX time
zone name, e.g. if you wanna know the time that's currently active in
Hawaii, try ``(setenv TZ US/Hawaii; date)'' :-)  The TZ name here is
any valid configuration file under /usr/share/zoneinfo.

Of course, all this stuff assumes that the kernel clock is running UTC.
The current release subtracts the value of its timezone option from the
CMOS time in order to get its internal time. And there is a major bug:
it always assumes the CMOS clock runs US DST rules, and it corrects for
this DST - even if the timezone option did not contain a ``dst'' speci-
fication! (Users with kernel source can delete those lines from /sys/
i386/isa/clock.c, or put an #ifdef DST around.)  There has been a long
internal discussion about how to improve this. Future releases will do
it much better. (The kernel will always boot with kernel time == CMOS
time. If the CMOS is at UTC, it's okay. Otherwise, a user-level program
started from /etc/rc will correct it.)
-- 
in real life: J"org Wunsch |   )  o o  | primary: joerg_wunsch@tcd-dresden.de
above 1.8 MHz:   DL 8 DTL  |    )  |   | private: joerg_wunsch@uriah.sax.de
                           | . * ) ==  |
          ``An elephant is a mouse with an operating system.''