[erlang-questions] microseconds since midnight

Ulf Wiger ulf.wiger@REDACTED
Sat Jan 9 00:33:43 CET 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Henning Diedrich wrote:
> Hi,
> 
> are now() and universaltime() incrementing their seconds count at the
> exact same time?
> 
> So that the seconds from calendar:time_to_seconds(universaltime()) and
> the microseconds from now() could simply be added up S*1000000+Ms?
> 
> Or would that risk having the microseconds going back to zero at
> different times then when the seconds counter is counted up?

now() is not guaranteed to show accurate wall-clock time. It is
guaranteed to always increment at least by one microsecond for each
call. It also normally adjusts its speed by up to 1% if it detects
a deviation from the system clock. This is to ensure that the
"real-time clock" of Erlang doesn't suddenly make a big leap in
time just because some clueless operator changed the system time
(or the system clock is in a time zone that obeys DST). As
Erlang timers rely on now(), big leaps can either cause all timers
to fire at once, or all of them going into deep sleep for a looong
time, both of which can be equally disastrous.

os:timestamp() looks like a now() object, but reads the system clock,
and should behave the way you want. This function is a recent
addition - R13, I think.

BR,
Ulf W
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAktHwNcACgkQtqqFieqzed1W7ACg92GMvW6WaN6vFRjyc3qzcaQM
+ZoAn3Obne7EZk2gF2029IEgVgWUFeXv
=XIOf
-----END PGP SIGNATURE-----
---------------------------------------------------

---------------------------------------------------

WE'VE CHANGED NAMES!

Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.

www.erlang-solutions.com



More information about the erlang-questions mailing list