[erlang-bugs 2] Re: [erlang-bugs] Time and system suspend

Attila Rajmund Nohl <>
Thu Mar 24 17:49:19 CET 2011


2011/3/24, Carlo Bertoldi <>:
> Hi, I think I've found a bug.
> Version I'm using: Erlang R13B03 (erts-5.7.4) [source] [smp:2:2]
> [rq:2] [async-threads:0] [hipe] [kernel-poll:false]
> on Linux.
>
> Steps to reproduce the problem:
> open an Erlang shell,
> calendar:now_to_local_time(erlang:now()).          It returns the correct
> time
>
> Suspend the computer without closing the erlang shell.
> Take a nap ;)
> Wake up the computer.
> calendar:now_to_local_time(erlang:now()).
>
> Now I can tell when I went to sleep, because the time printed is the
> time at the moment of the suspension, plus the time
> passed since the wake up. Please note that the system clock is fine.
> To double check, I quit the erl shell, than fired it up again, and
> then the time displayed was correct.

erlang:now() does not return the current time (despite its
documentation), but a tuple that is guaranteed to continuously
increase for subsequent calls. Use the os:timestamp() to get the
current time.


More information about the erlang-bugs mailing list