Project

General

Profile

Actions

Bug #4848

closed

DateTime.jd raises 'invalid fraction' when called with more than one argument

Added by philr (Phil  ) almost 13 years ago. Updated almost 13 years ago.

Status:
Rejected
Target version:
ruby -v:
ruby 1.9.3dev (2011-06-07 trunk 31946) [i686-linux]
Backport:
[ruby-core:36802]

Description

Since trunk revision 31862, the DateTime.jd function raises an ArgumentError with message 'invalid fraction' when it is called with more than one argument. For example,

DateTime.jd(Rational(39014323, 16), 0)
ArgumentError: invalid fraction
from (irb):2:in jd' from (irb):2 from /home/psr/ruby/build/bin/irb:12:in '

Calling DateTime.jd without the second parameter (and relying on the default value) works as expected:

DateTime.jd(Rational(39014323, 16))
=> #<DateTime: 1963-12-31T04:30:00+00:00 ((2438395j,16200s,0n),+0s,2299161j)>

I think the problem may be the 'argc > n' tests in the num2num_with_frac and num2int_with_frac #defines in ext/date/date_core.c. The attached patch changes the tests to 'argc < n'. This makes jd function properly again with more than one argument.


Files

date_core_num2_argc_tests.diff (573 Bytes) date_core_num2_argc_tests.diff Patch to change 'argc > n' to 'argc < n' in num2num_with_frac and num2int_with_frac philr (Phil  ), 06/07/2011 06:01 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0