Class: Faker::Time
Constant Summary
collapse
- TIME_RANGES =
{
:all => (0..23),
:day => (9..17),
:night => (18..23),
:morning => (6..11),
:afternoon => (12..17),
:evening => (17..21),
:midnight => (0..4)
}
Constants inherited
from Base
Base::Letters, Base::Numbers, Base::ULetters
Class Method Summary
collapse
Methods inherited from Date
birthday
Methods inherited from Base
bothify, fetch, flexible, letterify, method_missing, numerify, parse, rand_in_range, regexify, translate
Class Method Details
.backward(days = 365, period = :all) ⇒ Object
31
32
33
|
# File 'lib/faker/time.rb', line 31
def backward(days = 365, period = :all)
super(days).to_time + random_time(period)
end
|
.between(from, to, period = :all) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/faker/time.rb', line 14
def between(from, to, period = :all)
time_parameters = from.is_a?(::Time) && to.is_a?(::Time)
if time_parameters
random_time = Faker::Base::rand_in_range(from.to_f, to.to_f)
random_time = ::Time.at(random_time)
else
random_time = super(from, to).to_time + random_time(period)
end
random_time
end
|
.forward(days = 365, period = :all) ⇒ Object
27
28
29
|
# File 'lib/faker/time.rb', line 27
def forward(days = 365, period = :all)
super(days).to_time + random_time(period)
end
|