erlang time handling (in calendar.erl and erlang.erl)
Ulf Wiger
ulf@REDACTED
Sun Jan 30 23:11:48 CET 2005
Den 2005-01-29 22:14:55 skrev Håkan Stenholm
<hakan.stenholm@REDACTED>:
> Looking at the code in calendar.erl I would assume that the seconds
> retrieved with erlang:now() are in Unix time
> (http://en.wikipedia.org/wiki/Unix_time) - i.e. all days are treated as
> if they are 24*60*60 seconds long and leap seconds[1] are handled by
> extending certain seconds, i.e. reporting 23:59:59 twice instead of
> 23:59:59 followed by 23:59:60.
The calendar module doesn't rely on erlang:now() for time.
Instead, it uses erlang:localtime(), erlang:universaltime(),
and the conversion functions localtime_to_universaltime/1
and universaltime_to_localtime/1.
erlang:now() is to be considered as an internal real-time clock
which is loosely coupled to the system clock. It will periodically
sample the system clock and can adjust its own "speed" by +/- 1%
(if memory serves me) if the "now time" differs from the system
time. This can happen e.g. if the system clock is adjusted, either
manually or through an rdate() call. Since timeouts are coupled to
the erlang:now() clock, big jumps can have rather unpleasant
consequences.
Some functions, e.g. in snmp, use a combination of localtime()
and now in order to get sub-second precision. This is because
there is no time function in Erlang that reports the actual
system time with high enough precision.
/Uffe
--
Använder Operas banbrytande e-postklient: http://www.opera.com/m2/
More information about the erlang-questions
mailing list