Skip to content

Commit 8444328

Browse files
committed
Implemented a method that generates a series of random dates of a given size
1 parent eb871f3 commit 8444328

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
instance creation
2+
randomDates: aNumber
3+
4+
| lo hi rand |
5+
lo := 0.
6+
hi := (DateAndTime now) asSeconds.
7+
rand := Random new.
8+
9+
^ self newFrom: (
10+
(1 to: aNumber) collect: [ :each |
11+
| seconds |
12+
13+
"A random integer between lo and hi"
14+
seconds := (rand nextInt: (hi - lo)) + lo.
15+
(DateAndTime fromSeconds: seconds) asString ]).

0 commit comments

Comments
 (0)