From f6df2d9956a79eda048639107274ce60cbcf3542 Mon Sep 17 00:00:00 2001 From: Oscar NihlgÄrd Date: Fri, 13 Apr 2018 07:36:31 +0200 Subject: Sub second time resolution (#6978) * Add deprecation warnings to recently deprecated procs * Fix bad usage of the times module * Introduce sub second resolution * Fix usage of C's time() * Switch to nanosecond resolution * Make Time & Duration opaque again and fix some errors * Change back to TimeInterval for shorthands * Fix JS test * Fix build error for windows * Undeprecate epochTime * Documentation and minor changes * Lots of bugfixes and doc comments * Attempt to make travis & appveyor green * Fix edge cases for dealing with the local timezone * Workaround JS backend overflow/underflow bug * Use better workaround for not knowing the size of time_t * Use all available timezones for tests * Fix indentation * Add procs for accessing the fractional part of a duration * Order time units from smallest to largest since it makes more sense * Include months and years in `TimeUnit` * Review fix --- lib/pure/random.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/pure/random.nim') diff --git a/lib/pure/random.nim b/lib/pure/random.nim index 97ad12b99..968a326d2 100644 --- a/lib/pure/random.nim +++ b/lib/pure/random.nim @@ -191,8 +191,8 @@ 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 time = int64(times.epochTime() * 1_000_000_000) - randomize(time) + let now = times.getTime() + randomize(convert(Seconds, Nanoseconds, now.toUnix) + now.nanoseconds) {.pop.} -- cgit 1.4.1-2-gfad0