Class: Faker::Date
Direct Known Subclasses
Time
Constant Summary
Constants inherited
from Base
Base::Letters, Base::Numbers, Base::ULetters
Class Method Summary
collapse
Methods inherited from Base
bothify, fetch, flexible, letterify, method_missing, numerify, parse, rand_in_range, regexify, translate
Class Method Details
.backward(days = 365) ⇒ Object
18
19
20
21
22
23
|
# File 'lib/faker/date.rb', line 18
def backward(days = 365)
from = ::Date.today - days
to = ::Date.today - 1
between(from, to).to_date
end
|
.between(from, to) ⇒ Object
4
5
6
7
8
9
|
# File 'lib/faker/date.rb', line 4
def between(from, to)
from = get_date_object(from)
to = get_date_object(to)
Faker::Base::rand_in_range(from, to)
end
|
.birthday(min_age = 18, max_age = 65) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/faker/date.rb', line 25
def birthday(min_age = 18, max_age = 65)
t = ::Date.today
from = ::Date.new(t.year - min_age, t.month, t.day)
to = ::Date.new(t.year - max_age, t.month, t.day)
between(from, to).to_date
end
|
.forward(days = 365) ⇒ Object
11
12
13
14
15
16
|
# File 'lib/faker/date.rb', line 11
def forward(days = 365)
from = ::Date.today + 1
to = ::Date.today + days
between(from, to).to_date
end
|