Sha256: b9a10ae289f56bf813d1bc55fc008cbdb497ad7a8c2cf6cbcb66479ec6ffbdfe

Contents?: true

Size: 548 Bytes

Versions: 1

Compression:

Stored size: 548 Bytes

Contents

# mixin random time function from http://jroller.com/obie/entry/random_times_for_rails
class Time
  def self.random(params = {})
    years_back = params[:year_range] || 5
    year = (rand * (years_back)).ceil + (Time.now.year - years_back)
    month = (rand * 12).ceil
    day = (rand * 31).ceil
    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.1 lib/faker/medical/extensions/time.rb