now() and arithmetic
Mon May 6 14:23:04 CEST 2002
Matthias Lang <matthias@REDACTED> wrote:
> > Does TZ actually affect now() on some platforms?
>I think the manpage is wrong:
> It can only be used to check the local time of day
> if the time-zone info of the underlying operating
> system is properly configured.
>now() is defined as being the elapsed time since 00:00 GMT, Jan 1,
>1970, so it should be independent of the timezone in any case. Maybe
>the last sentence should be moved to the calendar module, under
It does sound weird - perhaps what it was supposed to say was that if
your local time is set right, but your time zone is not (a rather common
problem, actually), now() will *not* return time since the epoch even if
your OS claims to support this (neither will gettimeofday(), of course).
So I guess depending on your viewpoint, the answer to Bruce's question
above could actually be "yes".:-)
>Digging deeper: the value now() returns is based on
>sys_gettimeofday(), which, for all unix implementations, is a call to
>gettimeofday with a NULL second argument. Under linux that means TZ
>does not affect it.
As Bengt indicates, the second argument is irrelevant/obsolete/
deprecated and just generally useless. It's a remnant from a time when
someone could actually think that there was an easy way out of the
> as soon as NTP was configured, the system
>time would adjust itself by about a year.
>Now that the problem is fixed, the same series of events causes no
>greater damage than now() running 1% faster than it really should, so
>all of our internal timers are 1% shorter than nominal.
...And after running for a mere 100 years, the "time" returned by now()
will have caught up with reality.:-)
More information about the erlang-questions