Revert sub-second randomize(). Fixes randomize for JS backend. (#10000)

Fixes #9999.
This commit is contained in:
Dominik Picheta
2018-12-27 10:55:21 +00:00
committed by Andreas Rumpf
parent 65a52ecebb
commit 513a287c61

View File

@@ -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.}