Revert sub-second randomize(). Fixes randomize for JS backend. (#10000)
Fixes #9999.
This commit is contained in:
parent
65a52ecebb
commit
513a287c61
1 changed files with 6 additions and 2 deletions
|
|
@ -224,8 +224,12 @@ when not defined(nimscript):
|
||||||
proc randomize*() {.benign.} =
|
proc randomize*() {.benign.} =
|
||||||
## Initializes the random number generator with a "random"
|
## Initializes the random number generator with a "random"
|
||||||
## number, i.e. a tickcount. Note: Does not work for NimScript.
|
## number, i.e. a tickcount. Note: Does not work for NimScript.
|
||||||
let now = times.getTime()
|
when defined(js):
|
||||||
randomize(convert(Seconds, Nanoseconds, now.toUnix) + now.nanosecond)
|
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.}
|
{.pop.}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue