diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-10-24 09:35:02 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2019-10-24 12:34:51 -0700 |
commit | 5fe8943fdaf765dc01d986abafe85bd3eafb7814 (patch) | |
tree | ac2a37420db152e3721c3854dec4978d7794ccdb | |
parent | e8f90e73978c0321021c177fe3fa2623a8b3a4de (diff) | |
download | ruby-5fe8943fdaf765dc01d986abafe85bd3eafb7814.tar.gz |
Fix typo causing Date.new(year, month) to fail
Add a test for this case.
-rw-r--r-- | ext/date/date_core.c | 2 | ||||
-rw-r--r-- | test/date/test_date_new.rb | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/ext/date/date_core.c b/ext/date/date_core.c index decaec2d59..6301fe60ee 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -3438,7 +3438,7 @@ date_initialize(int argc, VALUE *argv, VALUE self) check_numeric(vd, "day"); num2int_with_frac(d, positive_inf); case 2: - check_numeric(vd, "month"); + check_numeric(vm, "month"); m = NUM2INT(vm); case 1: check_numeric(vy, "year"); diff --git a/test/date/test_date_new.rb b/test/date/test_date_new.rb index 2fb9846c9d..b90eadfadb 100644 --- a/test/date/test_date_new.rb +++ b/test/date/test_date_new.rb @@ -165,6 +165,10 @@ class TestDateNew < Test::Unit::TestCase assert_equal([2001, 2, 3, 4, 5, 6, 0], [d.year, d.mon, d.mday, d.hour, d.min, d.sec, d.offset]) assert_equal(1.to_r/2, d.sec_fraction) + + d = DateTime.civil(2001, 2) + assert_equal([2001, 2, 1, 0, 0, 0, 0], + [d.year, d.mon, d.mday, d.hour, d.min, d.sec, d.offset]) end def test_civil__neg |