nickva commented on a change in pull request #883: Fix erlang time module 
compatibility
URL: https://github.com/apache/couchdb/pull/883#discussion_r143835079
 
 

 ##########
 File path: src/couch/src/couch_uuids.erl
 ##########
 @@ -40,15 +40,23 @@ random() ->
     list_to_binary(couch_util:to_hex(crypto:strong_rand_bytes(16))).
 
 utc_random() ->
-    utc_suffix(couch_util:to_hex(crypto:strong_rand_bytes(9))).
-
-utc_suffix(Suffix) ->
-    Now = {_, _, Micro} = erlang:now(), % uniqueness is used.
-    Nowish = calendar:now_to_universal_time(Now),
-    Nowsecs = calendar:datetime_to_gregorian_seconds(Nowish),
-    Then = calendar:datetime_to_gregorian_seconds({{1970, 1, 1}, {0, 0, 0}}),
-    Prefix = io_lib:format("~14.16.0b", [(Nowsecs - Then) * 1000000 + Micro]),
-    list_to_binary(Prefix ++ Suffix).
+    Suffix = couch_util:to_hex(crypto:strong_rand_bytes(9)),
+    Now = os:timestamp(),
+    {UtcRandom, _NextClockSeq} = utc_suffix(Suffix, 0, Now),
 
 Review comment:
   I thought utc_random could be selected as one of the algorithms in the 
config. But you're right, it should probably get the same local clock sequence 
treatment as the utc_id
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to