Sha256: 15cb64bf4b97a0a8d2e537cf12ae173e03e5272457016dad2ce5ed6f76feb493

Contents?: true

Size: 602 Bytes

Versions: 1

Compression:

Stored size: 602 Bytes

Contents

# mixin random time function from http://jroller.com/obie/entry/random_times_for_rails
# updated from: http://www.jroller.com/obie/entry/quickly_generate_random_dates_in
class Time
  def self.random(params = {})
    years_back = params[:year_range] || 5
    year = Time.now.year - rand(years_back) - 1
    month = rand(12) + 1
    day = rand(31) + 1
    date = Time.local(year, month, day)

    series = [date]
    if params[:series]
      params[:series].each do |some_time_after|
        series << series.last + (rand * some_time_after).ceil
      end
      return series
    end

    date
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
faker-medical-0.5.2 lib/faker/medical/extensions/time.rb