summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-24 13:22:22 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-24 13:22:22 +0000
commit28e48d3fd8b7e9ae4d540a0111342a444a9ac061 (patch)
tree2b98ff3bc2b5840ac43f1b8b1410fa93311c569f /time.c
parent463633e4a934a00f869086a6ffbf84c6cb8ad630 (diff)
* time.c (time_init_1): Time.new will accept seconds as string or
int. [ruby-core:43569][Bug #6193] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/time.c b/time.c
index 0de32aed5f..7ec27a5693 100644
--- a/time.c
+++ b/time.c
@@ -845,6 +845,7 @@ static VALUE obj2vint(VALUE obj);
static int month_arg(VALUE arg);
static void validate_utc_offset(VALUE utc_offset);
static void validate_vtm(struct vtm *vtm);
+static int obj2subsecx(VALUE obj, VALUE *subsecx);
static VALUE time_gmtime(VALUE);
static VALUE time_localtime(VALUE);
@@ -2156,15 +2157,8 @@ time_init_1(int argc, VALUE *argv, VALUE time)
vtm.min = NIL_P(v[4]) ? 0 : obj2int(v[4]);
- vtm.sec = 0;
vtm.subsecx = INT2FIX(0);
- if (!NIL_P(v[5])) {
- VALUE sec = num_exact(v[5]);
- VALUE subsec;
- divmodv(sec, INT2FIX(1), &sec, &subsec);
- vtm.sec = NUM2INT(sec);
- vtm.subsecx = w2v(rb_time_magnify(v2w(subsec)));
- }
+ vtm.sec = NIL_P(v[5]) ? 0 : obj2subsecx(v[5], &vtm.subsecx);
vtm.isdst = -1;
vtm.utc_offset = Qnil;