Project

General

Profile

This project is closed and read-only.

Actions

Feature #4644

closed

DateTime.new does not work with Float

Feature #4644: DateTime.new does not work with Float

Added by Gibheer (Stefan Radomski) over 15 years ago. Updated over 15 years ago.

Status:
Closed
Target version:
-
[ruby-core:35997]

Description

When initializing a DateTime object, one can pass seconds as Floats, like 5.5. The decimals get added to sec_fraction. This works great in Ruby 1.9, but not in 1.8.
It fails in Line 527 of the "date.rb":http://redmine.ruby-lang.org/projects/ruby-18/repository/entry/lib/date.rb#L527 with the message "NoMethodError: undefined method `to_r' for 7325.5:Float".


Files

showcase.rb (121 Bytes) showcase.rb showcase of the problem Gibheer (Stefan Radomski), 05/04/2011 03:13 PM

Updated by nobu (Nobuyoshi Nakada) over 15 years ago Actions #1

  • Tracker changed from Bug to Feature

Updated by tadf (tadayoshi funaba) over 15 years ago Actions #2 [ruby-core:36867]

  • Assignee set to tadf (tadayoshi funaba)

Updated by cjheath (Clifford Heath) over 15 years ago Actions #3 [ruby-core:36871]

On 09/06/2011, at 9:38 AM, Stefan Radomski wrote:

When initializing a DateTime object, one can pass seconds as Floats,
like 5.5. The decimals get added to sec_fraction. This works great
in Ruby 1.9, but not in 1.8.

Even more amazing to me, is that you can't pass a DateTime to
DateTime.new,
and the same for Date. Surely you should be able to construct one from
another?

I should probably raise a separate issue for this...?

Clifford Heath.

Updated by tadf (tadayoshi funaba) over 15 years ago Actions #4

  • Status changed from Open to Closed

accepts flonum without Float#to_r.
anyway.

Actions

Also available in: PDF Atom