[前][次][番号順一覧][スレッド一覧]

ruby-changes:53082

From: nobu <ko1@a...>
Date: Mon, 22 Oct 2018 10:25:35 +0900 (JST)
Subject: [ruby-changes:53082] nobu:r65296 (trunk): time.c: optional arguments of Time::TM#initialize

nobu	2018-10-22 10:25:29 +0900 (Mon, 22 Oct 2018)

  New Revision: 65296

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65296

  Log:
    time.c: optional arguments of Time::TM#initialize
    
    * time.c (tm_initialize): arguments other than year are optional
      now as Time.new.

  Modified files:
    trunk/test/ruby/test_time_tz.rb
    trunk/time.c
Index: time.c
===================================================================
--- time.c	(revision 65295)
+++ time.c	(revision 65296)
@@ -5014,7 +5014,7 @@ tm_from_time(VALUE klass, VALUE time) https://github.com/ruby/ruby/blob/trunk/time.c#L5014
 {
     struct time_object *tobj;
     struct vtm vtm, *v;
-#ifdef TM_IS_TIME
+#if TM_IS_TIME
     VALUE tm;
     struct time_object *ttm;
 
@@ -5065,11 +5065,11 @@ tm_from_time(VALUE klass, VALUE time) https://github.com/ruby/ruby/blob/trunk/time.c#L5065
 static VALUE
 tm_initialize(int argc, VALUE *argv, VALUE tm)
 {
-#ifdef TM_IS_TIME
+#if TM_IS_TIME
     struct time_object *tobj = DATA_PTR(tm);
     struct vtm vtm;
 
-    rb_check_arity(argc, 6, 6);
+    rb_check_arity(argc, 1, 6);
     time_arg(argc, argv, &vtm);
     tobj->tzmode = TIME_TZMODE_UTC;
     tobj->timew = timegmw(&vtm);
@@ -5109,7 +5109,7 @@ tm_initialize(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/time.c#L5109
 static VALUE
 tm_to_time(VALUE tm)
 {
-#ifdef TM_IS_TIME
+#if TM_IS_TIME
     struct time_object *torig = get_timeval(tm);
     VALUE dup = time_s_alloc(rb_cTime);
     struct time_object *tobj = DATA_PTR(dup);
@@ -5279,7 +5279,7 @@ Init_Time(void) https://github.com/ruby/ruby/blob/trunk/time.c#L5279
     rb_cTime = rb_define_class("Time", rb_cObject);
     rb_include_module(rb_cTime, rb_mComparable);
 
-#ifdef TM_IS_TIME
+#if TM_IS_TIME
     rb_cTimeTM = rb_define_class_under(rb_cTime, "TM", rb_cTime);
 #else
     rb_cTimeTM = rb_struct_define_under(rb_cTime, "TM",
Index: test/ruby/test_time_tz.rb
===================================================================
--- test/ruby/test_time_tz.rb	(revision 65295)
+++ test/ruby/test_time_tz.rb	(revision 65296)
@@ -488,7 +488,7 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time_tz.rb#L488
     end
 
     def add_offset(t, ofs)
-      Time::TM.new(*Time.send(:apply_offset, *t.to_a[0, 6].reverse, ofs))
+      Time.utc(*Time.send(:apply_offset, *t.to_a[0, 6].reverse, ofs))
     rescue => e
       raise e.class, sprintf("%s: %p %+d", e.message, t, ofs)
     end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]