Hi,
I’m trying to create a method to return a random date within a range.
So far, I’ve come up with this…
require ‘parsedate’
def random_date (a, b)
adate = ParseDate.parsedate(a)
bdate = ParseDate.parsedate(b)
atime = Time.local(*adate)
btime = Time.local(*bdate)
atime + (rand * (atime - btime) )
end
…and it doesn’t seem to work–the dates returned aren’t within the
given range.
Can anyone spot what I’m doing wrong, or maybe is there a better way to
do this?
Best,
Jacob
Jacob P.
Trisignia
ph: 202-309-1047