Class: Faker::Time

Inherits:
Date show all
Defined in:
lib/faker/time.rb

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

between_except, birthday

Methods inherited from Base

bothify, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, sample, shuffle, translate, unique, with_locale

Class Method Details

.backward(days = 365, period = :all, format = nil) ⇒ Object



23
24
25
# File 'lib/faker/time.rb', line 23

def backward(days = 365, period = :all, format = nil)
  time_with_format(date_with_random_time(super(days), period), format)
end

.between(from, to, period = :all, format = nil) ⇒ Object



14
15
16
17
# File 'lib/faker/time.rb', line 14

def between(from, to, period = :all, format = nil)
  time = period == :between ? rand(from..to) : date_with_random_time(super(from, to), period)
  time_with_format(time, format)
end

.forward(days = 365, period = :all, format = nil) ⇒ Object



19
20
21
# File 'lib/faker/time.rb', line 19

def forward(days = 365, period = :all, format = nil)
  time_with_format(date_with_random_time(super(days), period), format)
end