From 513a287c61e6e461b013e75a7f5dbfa0136b606c Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Thu, 27 Dec 2018 10:55:21 +0000 Subject: Revert sub-second randomize(). Fixes randomize for JS backend. (#10000) Fixes #9999. --- lib/pure/random.nim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/pure/random.nim') 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.} -- cgit 1.4.1-2-gfad0