Method: PropCheck::Generators.time

Defined in:
lib/prop_check/generators.rb

.time(epoch: nil) ⇒ Object

Generates Time objects. Times start around the given epoch: and deviate more when size increases. when no epoch is set, PropCheck::Property::Configuration.default_epoch is used, which defaults to DateTime.now.

>> PropCheck::Generators.time(epoch: Date.new(2022, 11, 20)).sample(2, rng: Random.new(42), config: PropCheck::Property::Configuration.new)
=> [DateTime.parse("2022-11-17 07:11:59.999983907 +0000").to_time, DateTime.parse("2022-11-19 05:27:16.363618076 +0000").to_time]


809
810
811
# File 'lib/prop_check/generators.rb', line 809

def time(epoch: nil)
  datetime(epoch: epoch).map(&:to_time)
end