mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 01:14:41 +00:00
Revert sub-second randomize(). Fixes randomize for JS backend. (#10000)
Fixes #9999.
This commit is contained in:
committed by
Andreas Rumpf
parent
65a52ecebb
commit
513a287c61
@@ -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.}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user