*BSD News Article 65491


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.rmit.EDU.AU!news.unimelb.EDU.AU!munnari.OZ.AU!spool.mu.edu!howland.reston.ans.net!newsfeed.internetmci.com!news.mathworks.com!fu-berlin.de!zib-berlin.de!news.tu-chemnitz.de!irz401!uriah.heep!news
From: j@uriah.heep.sax.de (J Wunsch)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Setting the time and date
Date: 7 Apr 1996 17:46:59 GMT
Organization: Private BSD site, Dresden
Lines: 38
Message-ID: <4k8v2j$178@uriah.heep.sax.de>
References: <4k80h9$4nj@ginger.lei.net>
Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch)
NNTP-Posting-Host: localhost.heep.sax.de
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Newsreader: knews 0.9.3

wongc@hits.net (Strange Quark) writes:

> You see, if I set the date using the date command (and the CMOS clock is 
> set correctly), only the root shells seem to get the right date.  The 
> ordinary user's shell dates' are off.

What's a ``shell date'', in your opinion?

The date and time information is stored inside the kernel as the
difference in seconds to the ``Unix epoch'', Jan 1, 1970, 00:00:00 UTC
(I think it's been GMT by that time what we call UTC now).

User processes can fetch the current time from the kernel by the
syscall gettimeofday(2), or by the ANSI C utility function time(3).  A
changed time in the kernel will immediately be reflected in the next
call to gettimeofday(2), regardless of which user performs this system
call, or which might be the parent shell of the inquiring process.

The application itself will have to convert this time into something
useful, this is often performed by localtime(3).  That's the point
where also the timezone information will be considered, either via the
environmental variable ``TZ'', or short of this, by the default
timezone information as stored in /etc/localtime.

Different user shells with different values of the timezone variable
will display a different localtime for one and the same Unix (kernel)
time.  This is intention.  For example, when i'm logging into
freefall, i usually set TZ to ``MET'', so all Unix times (including
the file timestamps) will display in the same timezone as i'm actually
working at home, irrespective that people sitting in California will
consider this time 9 hours off their own one.

-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)