erlang time handling (in calendar.erl and erlang.erl)

Ulf Wiger ulf@REDACTED
Mon Jan 31 07:38:56 CET 2005

Den 2005-01-31 00:42:49 skrev Håkan Stenholm  

> The function now_to_datetime/1 and now_to_universal_time/1 pretty much  
> appear to be designed to take erlang:now/0 as input, I at least can't  
> find any other function that returns {MegaSecs,Secs,Microsecs} as output.
> See calendar.erl source (R10B-2):

True, and it doesn't appear as if these functions handle leap
seconds. But OTOH, since erlang:now() periodically samples the
system clock and adjusts itself accordingly, there should be
no need to insert leap seconds. Event though erlang:now()
normally follows the system clock quite closely, there is no
guarantee that it will shows accurate time at any given sample.
A one-second deviation should take erlang:now() at least 100
seconds to compensate for, since the adjustments stay within
1%. If you change the date on your system while erlang is
running, erlang:now() will be way off the mark for a loong

In AXD 301, we have a little monitor utility that will raise
an alarm if the time returned by now_to_datetime/1 differs
significantly from the system clock. While this doesn't threaten
system operation, it may lead to confusing log entries, where
some time values are derived from erlang:now() and others from
the system clock. Restarting one processor at a time will reset
erlang:now() in the whole system without calls being lost.


More information about the erlang-questions mailing list