diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-28 02:41:31 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-28 02:41:31 +0000 |
commit | 09a4ae1bbc8c611db9d87842a9ff249005599855 (patch) | |
tree | 39fbfde66e61cab4b1aae87eb98c694006052597 | |
parent | 0dcb387abe9570711af5638eac474157eddbfef2 (diff) | |
download | ruby-09a4ae1bbc8c611db9d87842a9ff249005599855.tar.gz |
* ext/date/date_core.c (date_s_today): use int for year.
* ext/date/date_core.c (datetime_s_now): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ext/date/date_core.c | 18 | ||||
-rw-r--r-- | test/date/test_date_base.rb | 4 |
3 files changed, 19 insertions, 9 deletions
@@ -1,3 +1,9 @@ +Mon Mar 28 11:38:08 2011 NARUSE, Yui <naruse@ruby-lang.org> + + * ext/date/date_core.c (date_s_today): use int for year. + + * ext/date/date_core.c (datetime_s_now): ditto. + Mon Mar 28 11:07:41 2011 NAKAMURA Usaku <usa@ruby-lang.org> * ext/extmk.rb: set MFLAGS from MAKEFLAGS when using nmake. diff --git a/ext/date/date_core.c b/ext/date/date_core.c index bb51bd8e8b..2a710d5f4d 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -1321,7 +1321,7 @@ date_s_today(int argc, VALUE *argv, VALUE klass) double sg; time_t t; struct tm tm; - long y; + int y; int m, d; rb_scan_args(argc, argv, "01", &vsg); @@ -1343,15 +1343,15 @@ date_s_today(int argc, VALUE *argv, VALUE klass) rb_raise(rb_eArgError, "cannot create"); if (isinf(sg) && sg < 0) - return d_lite_s_new_internal(klass, 0, sg, (int)y, m, d, + return d_lite_s_new_internal(klass, 0, sg, y, m, d, LIGHT_MODE | HAVE_CIVIL); else { long jd; int ns; - civil_to_jd((int)y, m, d, sg, &jd, &ns); + civil_to_jd(y, m, d, sg, &jd, &ns); - return d_lite_s_new_internal(klass, jd, sg, (int)y, m, d, + return d_lite_s_new_internal(klass, jd, sg, y, m, d, LIGHT_MODE | HAVE_JD | HAVE_CIVIL); } } @@ -3022,8 +3022,8 @@ datetime_s_now(int argc, VALUE *argv, VALUE klass) #endif time_t sec; struct tm tm; - long y, sf; - int m, d, h, min, s, of; + long sf; + int y, m, d, h, min, s, of; rb_scan_args(argc, argv, "01", &vsg); @@ -3067,20 +3067,20 @@ datetime_s_now(int argc, VALUE *argv, VALUE klass) if (isinf(sg) && sg < 0) return dt_lite_s_new_internal(klass, 0, 0, sf, of, sg, - (int)y, m, d, h, min, s, + y, m, d, h, min, s, LIGHT_MODE | HAVE_CIVIL | HAVE_TIME); else { long jd; int ns; - civil_to_jd((int)y, m, d, sg, &jd, &ns); + civil_to_jd(y, m, d, sg, &jd, &ns); return dt_lite_s_new_internal(klass, jd_local_to_utc(jd, time_to_df(h, min, s), of), 0, sf, of, sg, - (int)y, m, d, h, min, s, + y, m, d, h, min, s, LIGHT_MODE | HAVE_JD | HAVE_CIVIL | HAVE_TIME); } diff --git a/test/date/test_date_base.rb b/test/date/test_date_base.rb index a266058413..912c45cca3 100644 --- a/test/date/test_date_base.rb +++ b/test/date/test_date_base.rb @@ -193,6 +193,10 @@ class TestDateBase < Test::Unit::TestCase end end + def test_jd + assert_equal(1<<33, Date.jd(1<<33)) + end + def test_mjd jd = Date.__send__(:mjd_to_jd, 51321) mjd = Date.__send__(:jd_to_mjd, jd) |