Class: Faker::Time

Inherits:
Date show all
Defined in:
lib/faker/default/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)
}.freeze

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, disable_enforce_available_locales, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale

Class Method Details

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


25
26
27
# File 'lib/faker/default/time.rb', line 25

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


16
17
18
19
# File 'lib/faker/default/time.rb', line 16

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


21
22
23
# File 'lib/faker/default/time.rb', line 21

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