Browse Source

Merge pull request #3 from ii000314/fix-warnings

Fix warnings. Bump app version.
Yuri Zhloba 8 years ago
parent
commit
b78c2678fb
4 changed files with 11 additions and 7 deletions
  1. 2 1
      .gitignore
  2. 1 1
      src/herd.app.src
  3. 4 2
      src/herd_datetime.erl
  4. 4 3
      src/herd_rand.erl

+ 2 - 1
.gitignore

@@ -1,4 +1,5 @@
 _build
 _build
 erl_crash.dump
 erl_crash.dump
 rebar.lock
 rebar.lock
-.idea
+_build
+.idea

+ 1 - 1
src/herd.app.src

@@ -1,7 +1,7 @@
 {application, herd,
 {application, herd,
  [
  [
   {description, "Base library for erlang projects"},
   {description, "Base library for erlang projects"},
-  {vsn, "1"},
+  {vsn, "1.3.2"},
   {modules, []},
   {modules, []},
   {registered, []},
   {registered, []},
   {applications, [kernel, stdlib]},
   {applications, [kernel, stdlib]},

+ 4 - 2
src/herd_datetime.erl

@@ -26,12 +26,14 @@
 
 
 -spec now() -> timestamp().
 -spec now() -> timestamp().
 now() ->
 now() ->
-    erlang:system_time(seconds).
+    os:system_time(seconds).
+
 
 
 
 
 -spec now_micro() -> timestamp_micro().
 -spec now_micro() -> timestamp_micro().
 now_micro() ->
 now_micro() ->
-    erlang:system_time(micro_seconds) / 1000000.
+    os:system_time(micro_seconds) * 1.0e-6.
+
 
 
 
 
 -spec datetime_from_db(db_datetime()) -> calendar:datetime().
 -spec datetime_from_db(db_datetime()) -> calendar:datetime().

+ 4 - 3
src/herd_rand.erl

@@ -8,8 +8,8 @@
 %% sets random seed for current process
 %% sets random seed for current process
 -spec init_crypto() -> ok.
 -spec init_crypto() -> ok.
 init_crypto() ->
 init_crypto() ->
-    <<A:32, B:32, C:32>> = crypto:rand_bytes(12),
-    random:seed({A,B,C}),
+    <<A:32, B:32, C:32>> = crypto:strong_rand_bytes(12),
+    rand:seed({A,B,C}),
     ok.
     ok.
 
 
 
 
@@ -44,4 +44,5 @@ md5hex(Str) ->
 
 
 %% generates random md5 hash
 %% generates random md5 hash
 -spec hex() -> string().
 -spec hex() -> string().
-hex() -> md5hex(integer_to_list(erlang:phash2({erlang:system_time(), make_ref()}))).
+hex() -> md5hex(integer_to_list(erlang:phash2({os:system_time(micro_seconds), make_ref()}))).
+