Phil Smith III wrote:
I have a C POSIX application that writes timestamps on its output. It's always
produced a GMT timestamp (pardon me, UTC), and that's sort of fugly, so I
thought maybe I could fix it.
The fundamental problem with "local time" is the definition of "local".
If we make the assumption that the machine clock is kept in UTC (GMT), then
the local time is simply the different from UTC to where one might be at
that
moment on the globe.
Now - consider the problem of a terminal connected to a fairly remote
system.
The user may consider himself in a different timezone from the system; hence
his idea of "local" is different than the, say, the operator console
which happens
to be physically adjacent to the actual hardware device that keeps track
of the
time.
This is why UNIX/POSIX has the TZ environment variable - one user can set a
different timezone than another. And this is also why a "global"
setting of
TZ in, say, /etc/rc isn't always the right idea. You may have multiple
users in
multiple timezones.
Some systems might go as far as keeping a database of sorts for
terminals, and
having the /etc/rc script make a good guess as to what the proper TZ setting
might be.
This is also why the ssh (and other remote-connect-over-the-internet
protocols)
have mechanisms for passing the value of the TZ environment variable to the
remote shell. The user connecting can say "hey - when you connect, set
this
to be my TZ value."
All that is well and good - but then we run into the problem of programs
being
dub'd without going thru the typical UNIX start-up... what TZ should
they get then?
The Dignus runtime main() start-up from a BATCH or TSO start examines
the CVTTZ
value and constructs a TZ that offers the proper offset from UTC (again,
this assumes
the machine's clock is set to UTC and that CVTTZ is properly set.)
This basically
gives you a "local time" for the machine, the user would need to set TZ
to something
else if they are not in the same locality as the machine. Under a USS
start-up, we
inherit the TZ environment variable from the BPX environment.
Thus - the entire question about "what time is it" is totally answered
when you
can reliably answer the question of "where are you?"
- Dave Rivers -
--
riv...@dignus.com Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN