Module: Faker::Time
Constant Summary
collapse
- MONTHS =
k %w(January February March April May June July August September October November December)
Instance Method Summary
collapse
const_missing, k, underscore
Instance Method Details
#date(params = {}) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/ffakerer/time.rb', line 12
def date(params={})
years_back = params[:year_range] || 5
latest_year = params [:year_latest] || 0
year = (rand * (years_back)).ceil + (::Time.now.year - latest_year - years_back)
month = (rand * 12).ceil
day = (rand * 31).ceil
series = [date = ::Time.local(year, month, day)]
if params[:series]
params[:series].each do |some_time_after|
series << series.last + (rand * some_time_after).ceil
end
return series
end
date.strftime "%Y-%m-%d %T %z"
end
|
#month ⇒ Object
8
9
10
|
# File 'lib/ffakerer/time.rb', line 8
def month
MONTHS.rand
end
|