/usr/share/rubygems-integration/all/gems/faker-1.6.6/lib/faker/time.rb is in ruby-faker 1.6.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | module Faker
class Time < Date
TIME_RANGES = {
:all => (0..23),
:day => (9..17),
:night => (18..23),
:morning => (6..11),
:afternoon => (12..17),
:evening => (17..21),
:midnight => (0..4)
}
class << self
def between(from, to, period = :all)
date_with_random_time(super(from, to), period)
end
def forward(days = 365, period = :all)
date_with_random_time(super(days), period)
end
def backward(days = 365, period = :all)
date_with_random_time(super(days), period)
end
private
def date_with_random_time(date, period)
::Time.local(date.year, date.month, date.day, hours(period), minutes, seconds)
end
def hours(period)
raise ArgumentError, 'invalid period' unless TIME_RANGES.has_key? period
TIME_RANGES[period].to_a.sample
end
def minutes
seconds
end
def seconds
(0..59).to_a.sample
end
end
end
end
|