[erlang-questions] calendar now_to_universal_time/1 vs. universal_time/0
Mon Sep 27 19:00:13 CEST 2010
On 27 Sep 2010, at 18:25, Pierpaolo Bernardi wrote:
> On Mon, Sep 27, 2010 at 18:21, Ryan Zezeski <rzezeski@REDACTED> wrote:
>> This is, essentially, the question I'm asking. Should I prefer one over the
>> other for *any* reason? Right now, I prefer universal_time because it's
>> less typing :)
> A perfectly good reason. It's also a tiny bit clearer.
erlang:now() is actually a bit different from the calendar clock.
It can, by definition, never jump backwards.
It will also attempt not to make large adjustments of any kind, so if it detects
that there is a large difference between the system clock and the erlang:now()
clock, the now() clock will speed up or slow down 1% in order to converge
with the actual time, without disturbing timeouts etc. which rely on now() to
provide a smooth representation of system real-time.
In other words, erlang:universal_time/0 will return the actual time, whereas
erlang:now() may, under certain circumstances, differ quite significantly from actual time.
Ulf Wiger, CTO, Erlang Solutions, Ltd.
More information about the erlang-questions