Bug #6864
closedbad value for range when using infinity with date or time
Description
Steps to reproduce:
require 'date'
Range.new(Date.today, 1.0/0.0) # works
Range.new(-1.0/0.0, Date.today) # fails
Range.new(Time.now, 1.0/0.0) # fails
Range.new(-1.0/0.0, Time.now) # fails
Tested on 1.9.3 and trunk. I think this is a bug, because there is no logic error. just ranges without one bound.
Updated by slbug (Alex Grebennik) over 12 years ago
And sometimes range behavior cant be understood - Range.new(Date.new(0), BigDecimal.new(9))
Updated by mame (Yusuke Endoh) over 12 years ago
- Status changed from Open to Assigned
- Assignee set to tadf (tadayoshi funaba)
- Target version set to 2.0.0
This is caused by the following behavior.
p Date.today <=> 1.0 #=> 1
p 1.0 <=> Date.today #=> nil
Funaba-san, what do you think?
It may be good to provide Date#coerce.
--
Yusuke Endoh mame@tsg.ne.jp
Updated by tadf (tadayoshi funaba) over 12 years ago
this asymmetry is intentional.
i don't want to accept aNum + aDate.
Range's spec is variable.
Updated by mame (Yusuke Endoh) over 12 years ago
- Assignee changed from tadf (tadayoshi funaba) to matz (Yukihiro Matsumoto)
- Target version changed from 2.0.0 to 2.6
I see, thank you. Then, addressing this issue requires
changing Range's spec, which is too heavy from this time.
I postpone this to next minor.
--
Yusuke Endoh mame@tsg.ne.jp
Updated by jeremyevans0 (Jeremy Evans) over 5 years ago
- Status changed from Assigned to Closed
I think this issue is now solved by beginless and endless ranges.