now() -> now_to_tz

Per Hedeland per@REDACTED
Fri Feb 28 11:15:09 CET 2003

Ulf Wiger <etxuwig@REDACTED> wrote:
>In AXD 301, we decided to provide a web page where the
>operator can define the information necessary whatever
>timezone [s]he wants the switch to be in. We then use
>os:setenv("TZ",...) to get correct localtime in the Erlang

Unfortunately the effect on localtime() and friends when setting TZ
after process startup is system-dependant, or at least "on some systems
dependant on what the process has done before that" (or maybe just plain
buggy:-). E.g. on a pretty recent RH Linux (Erlang/OTP R8-something):

1> time().
2> os:cmd("TZ=America/Los_Angeles date").
"Fri Feb 28 01:49:30 PST 2003\n"
3> os:putenv("TZ","America/Los_Angeles").
4> time().

I.e. zero effect. While on e.g. Solaris 8:

1> time().
2> os:cmd("TZ=US/Pacific date").
"Fri Feb 28 01:52:54 PST 2003\n"
3> os:putenv("TZ","US/Pacific").
4> time().                      

(Solaris 8 as shipped doesn't have America/Los_Angeles, but US/Pacific
is the same thing, though not available on some *other* OSes - sigh...)

> The rest of the system is always set for UTC. It's
>worked for us so far.

I'd think that would be a bit confusing, e.g. if you ever need to
correlate Erlang-produced logs and system-produced ones.


More information about the erlang-questions mailing list