summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2018-12-27 10:55:21 +0000
committerAndreas Rumpf <rumpf_a@web.de>2018-12-27 11:55:21 +0100
commit513a287c61e6e461b013e75a7f5dbfa0136b606c (patch)
tree02697fc002a66a38f5d50f4a517c38d68ac503c4 /lib/pure
parent65a52ecebb98774777f1792f5696b211c51926af (diff)
downloadNim-513a287c61e6e461b013e75a7f5dbfa0136b606c.tar.gz
Revert sub-second randomize(). Fixes randomize for JS backend. (#10000)
Fixes #9999.
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/random.nim8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/pure/random.nim b/lib/pure/random.nim
index d6501c87e..26e6740ea 100644
--- a/lib/pure/random.nim
+++ b/lib/pure/random.nim
@@ -224,8 +224,12 @@ when not defined(nimscript):
   proc randomize*() {.benign.} =
     ## Initializes the random number generator with a "random"
     ## number, i.e. a tickcount. Note: Does not work for NimScript.
-    let now = times.getTime()
-    randomize(convert(Seconds, Nanoseconds, now.toUnix) + now.nanosecond)
+    when defined(js):
+      let time = int64(times.epochTime() * 1_000_000_000)
+      randomize(time)
+    else:
+      let now = times.getTime()
+      randomize(convert(Seconds, Nanoseconds, now.toUnix) + now.nanosecond)
 
 {.pop.}