class Faker::Time
Constants
- TIME_RANGES
Public Class Methods
backward(days = 365, period = :all)
click to toggle source
Calls superclass method
Faker::Date.backward
# File lib/faker/time.rb, line 22 def backward(days = 365, period = :all) date_with_random_time(super(days), period) end
between(from, to, period = :all)
click to toggle source
Calls superclass method
Faker::Date.between
# File lib/faker/time.rb, line 14 def between(from, to, period = :all) date_with_random_time(super(from, to), period) end
forward(days = 365, period = :all)
click to toggle source
Calls superclass method
Faker::Date.forward
# File lib/faker/time.rb, line 18 def forward(days = 365, period = :all) date_with_random_time(super(days), period) end
Private Class Methods
date_with_random_time(date, period)
click to toggle source
# File lib/faker/time.rb, line 28 def date_with_random_time(date, period) ::Time.local(date.year, date.month, date.day, hours(period), minutes, seconds) end
hours(period)
click to toggle source
# File lib/faker/time.rb, line 32 def hours(period) raise ArgumentError, 'invalid period' unless TIME_RANGES.has_key? period TIME_RANGES[period].to_a.sample end
minutes()
click to toggle source
# File lib/faker/time.rb, line 37 def minutes seconds end
seconds()
click to toggle source
# File lib/faker/time.rb, line 41 def seconds (0..59).to_a.sample end