Topic: Radom date and time [SOLVED]

i am using a fabricator to create some fake data for a dev application.

and i have a calendar task that i want to populate with random start date and end dates and random start and end times.

i know if do

oncall_start { rand(10.days).from_now }
oncall_end { rand(2.years).from_now }

but i would like to gate the date in one time in 2 different fields

  start_date {  }
  end_date {  }
  start_time {  }
  end_time {  }

is this what a time should look like in the DB

:start_time => 2000-01-01 18:13:45 UTC

Last edited by moiseszaragoza (2012-06-26 09:25:13)

Re: Radom date and time [SOLVED]

i was just playing around and I did

  start_date { rand(10.days).from_now  }
  end_date { rand(2.years).from_now }
  start_time { rand(2.years).from_now.time }
  end_time { rand(2.years).from_now.time }

and i am getting
      :start_date => Thu, 28 Jun 2012 15:46:40 UTC +00:00,
      :end_date => Fri, 20 Jun 2014 03:06:00 UTC +00:00,
      :start_time => 2013-05-17 18:13:45 UTC,
      :end_time => 2013-07-30 16:20:01 UTC

When i look at the DB it looks like

      :start_date => Mon, 02 Jul 2012,
      :end_date => Mon, 10 Mar 2014,
      :start_time => 2000-01-01 18:13:45 UTC,
      :end_time => 2000-01-01 20:41:21 UTC