summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-28 12:05:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-28 12:05:18 +0000
commitd59ad98f6accb33a2e15227f8d963f9041df0f56 (patch)
tree0e78a85b28f5f8020e3b8aebdbd69e7db1c40dcd /time.c
parentc4be18c28bf40b13674d0bd224b8029e87ea0257 (diff)
time.c: ignore 7th arg
* time.c (tm_initialize): allow 7th argument as well as Time#initialize, but just ignore. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/time.c b/time.c
index d0c1d475c8..c76a179b72 100644
--- a/time.c
+++ b/time.c
@@ -5065,7 +5065,7 @@ tm_from_time(VALUE klass, VALUE time)
/*
* call-seq:
*
- * Time::TM.new(year, month, day, hour, min, sec) -> tm
+ * Time::TM.new(year, month=nil, day=nil, hour=nil, min=nil, sec=nil, tz=nil) -> tm
*
* Creates new Time::TM object.
*/
@@ -5073,32 +5073,30 @@ tm_from_time(VALUE klass, VALUE time)
static VALUE
tm_initialize(int argc, VALUE *argv, VALUE tm)
{
-#if TM_IS_TIME
- struct time_object *tobj = DATA_PTR(tm);
- struct vtm vtm;
-
- rb_check_arity(argc, 1, 6);
- time_arg(argc, argv, &vtm);
- tobj->tzmode = TIME_TZMODE_UTC;
- tobj->timew = timegmw(&vtm);
- tobj->vtm = vtm;
- return tm;
-#else
- int i = 0;
struct vtm vtm;
wideval_t t;
+ if (rb_check_arity(argc, 1, 7) > 6) argc = 6;
time_arg(argc, argv, &vtm);
t = timegmw(&vtm);
- RSTRUCT_SET(tm, i++, INT2FIX(vtm.sec));
- RSTRUCT_SET(tm, i++, INT2FIX(vtm.min));
- RSTRUCT_SET(tm, i++, INT2FIX(vtm.hour));
- RSTRUCT_SET(tm, i++, INT2FIX(vtm.mday));
- RSTRUCT_SET(tm, i++, INT2FIX(vtm.mon));
- RSTRUCT_SET(tm, i++, vtm.year);
- RSTRUCT_SET(tm, i++, w2v(rb_time_unmagnify(t)));
- return tm;
+ {
+#if TM_IS_TIME
+ struct time_object *tobj = DATA_PTR(tm);
+ tobj->tzmode = TIME_TZMODE_UTC;
+ tobj->timew = t;
+ tobj->vtm = vtm;
+#else
+ int i = 0;
+ RSTRUCT_SET(tm, i++, INT2FIX(vtm.sec));
+ RSTRUCT_SET(tm, i++, INT2FIX(vtm.min));
+ RSTRUCT_SET(tm, i++, INT2FIX(vtm.hour));
+ RSTRUCT_SET(tm, i++, INT2FIX(vtm.mday));
+ RSTRUCT_SET(tm, i++, INT2FIX(vtm.mon));
+ RSTRUCT_SET(tm, i++, vtm.year);
+ RSTRUCT_SET(tm, i++, w2v(rb_time_unmagnify(t)));
#endif
+ }
+ return tm;
}
/* call-seq: