Project

General

Profile

Actions

Bug #12961

closed

Bad value for range using infinity for Date or Time

Added by loudandwicked (Damjan Cilenšek) over 7 years ago. Updated over 4 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.3.2p217 (2016-11-15 revision 56796) [x86_64-darwin16]
[ruby-core:78220]

Description

How to reproduce:

-Float::INFINITY...Float::INFINITY # works
Date.today...Float::INFINITY # works
-Float::INFINITY...Date.today # fails with "ArgumentError: bad value for range"
Time.now...Float::INFINITY #fails with "ArgumentError: bad value for range"
-Float::INFINITY...Time.now #fails with "ArgumentError: bad value for range"

There's one similar bug report for 1.9.3, obviously still not resolved

Updated by shyouhei (Shyouhei Urabe) over 7 years ago

  • Status changed from Open to Assigned

Matz, please decide how it should work.

Updated by znz (Kazuhiro NISHIYAMA) almost 5 years ago

  • Assignee set to matz (Yukihiro Matsumoto)

Ruby 2.6 supports endless range, and ruby 2.7 will support beginless range.

Updated by matz (Yukihiro Matsumoto) over 4 years ago

Since both Time and Date work with float numbers at the other ends of the ranges, it should accept Float::INFINITY as well.

Matz.

Updated by naruse (Yui NARUSE) over 4 years ago

matz (Yukihiro Matsumoto) wrote:

Since both Time and Date work with float numbers at the other ends of the ranges, it should accept Float::INFINITY as well.

Matz.

It looks only Date supports float number.

Updated by matz (Yukihiro Matsumoto) over 4 years ago

So we only need to fix Date class. I don't think we should enhance Time ranges to support Integer/Float.

Matz.

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

I've submitted a pull request to allow -Float::Infinity...Date.today: https://github.com/ruby/date/pull/13

Actions #7

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Status changed from Assigned to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0