From 052140fb3ccd4b386d8d98ba7355d676c1e0693d Mon Sep 17 00:00:00 2001 From: Andinus Date: Wed, 18 Mar 2020 23:04:21 +0530 Subject: Initial commit for Cetus v0.5.0 --- pkg/apod/rand.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pkg/apod/rand.go (limited to 'pkg/apod/rand.go') diff --git a/pkg/apod/rand.go b/pkg/apod/rand.go new file mode 100644 index 0000000..cf92784 --- /dev/null +++ b/pkg/apod/rand.go @@ -0,0 +1,25 @@ +package apod + +import ( + "math/rand" + "time" +) + +// RandDate returns a random date between 1995-06-16 & today +func RandDate() string { + var ( + min int64 + max int64 + sec int64 + delta int64 + date string + ) + min = time.Date(1995, 6, 16, 0, 0, 0, 0, time.UTC).Unix() + max = time.Now().UTC().Unix() + delta = max - min + + sec = rand.Int63n(delta) + min + date = time.Unix(sec, 0).Format("2006-01-02") + + return date +} -- cgit 1.4.1-2-gfad0