From 0e798b4c51ebc13105395f45769e91b5fbf089b8 Mon Sep 17 00:00:00 2001 From: Sylvio Tavares Date: Thu, 1 Aug 2019 18:31:02 -0400 Subject: [PATCH] time: fix rand() --- vlib/time/time.v | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/vlib/time/time.v b/vlib/time/time.v index 42f4b15a04..2899404f1f 100644 --- a/vlib/time/time.v +++ b/vlib/time/time.v @@ -46,14 +46,10 @@ pub fn now() Time { } pub fn random() Time { - return Time { - year: rand.next(2) + 201 - month: rand.next(12) + 1 - day: rand.next(30) + 1 - hour: rand.next(24) - minute: rand.next(60) - second: rand.next(60) - } + now_unix := now().uni + rand_unix := rand.next(now_unix) + + return time.unix(rand_unix) } const (