Class: Time
- Defined in:
- lib/propr/random/time.rb,
lib/propr/shrink/time.rb
Constant Summary collapse
- MIN =
MIN = Time.at(0) # 1969-12-31 00:00:00 UTC
Time.at(-30610224000)
- MAX =
9999-12-31 23:59:59 UTC
Time.at(253402300799)
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.random(options = {}, m = Propr::Random) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/propr/random/time.rb', line 6 def random( = {}, m = Propr::Random) min = ([:min] || MIN).to_f max = ([:max] || MAX).to_f m.bind(Float.random(.merge(min: min, max: max))) do |ms| m.unit(at(ms)) end end |
Instance Method Details
#shrink ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/propr/shrink/time.rb', line 2 def shrink Array.unfold(to_f) do |seed| zero = 0 # 1969-12-31 00:00:00 UTC seed_ = zero + (seed - zero) / 2 ((seed - seed_).abs > 1e-2).maybe([self + zero - seed, seed_]) end end |