Project

General

Profile

Actions

Bug #6864

closed

bad value for range when using infinity with date or time

Added by slbug (Alex Grebennik) over 11 years ago. Updated over 4 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
[ruby-core:47160]

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 11 years ago

And sometimes range behavior cant be understood - Range.new(Date.new(0), BigDecimal.new(9))

Updated by mame (Yusuke Endoh) over 11 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

Updated by tadf (tadayoshi funaba) over 11 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 11 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

Actions #5

Updated by naruse (Yui NARUSE) over 6 years ago

  • Target version deleted (2.6)

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Status changed from Assigned to Closed

I think this issue is now solved by beginless and endless ranges.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0