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

ruby-changes:52813

From: nobu <ko1@a...>
Date: Fri, 12 Oct 2018 11:25:43 +0900 (JST)
Subject: [ruby-changes:52813] nobu:r65025 (trunk): Load as FIXOFF mode if zone is present

nobu	2018-10-12 11:25:38 +0900 (Fri, 12 Oct 2018)

  New Revision: 65025

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

  Log:
    Load as FIXOFF mode if zone is present

  Modified files:
    trunk/test/ruby/test_time_tz.rb
    trunk/time.c
Index: time.c
===================================================================
--- time.c	(revision 65024)
+++ time.c	(revision 65025)
@@ -1257,7 +1257,9 @@ gmtimew(wideval_t timew, struct vtm *res https://github.com/ruby/ruby/blob/trunk/time.c#L1257
     result->wday = tm.tm_wday;
     result->yday = tm.tm_yday+1;
     result->isdst = tm.tm_isdst;
+#if 0
     result->zone = rb_fstring_usascii("UTC");
+#endif
 
     return result;
 }
@@ -1716,8 +1718,7 @@ PACKED_STRUCT_UNALIGNED(struct time_obje https://github.com/ruby/ruby/blob/trunk/time.c#L1718
 #define TZMODE_FIXOFF_P(tobj) ((tobj)->tzmode == TIME_TZMODE_FIXOFF)
 #define TZMODE_SET_FIXOFF(tobj, off) \
     ((tobj)->tzmode = TIME_TZMODE_FIXOFF, \
-     (tobj)->vtm.utc_offset = (off), \
-     (tobj)->vtm.zone = Qnil)
+     (tobj)->vtm.utc_offset = (off))
 
 #define TZMODE_COPY(tobj1, tobj2) \
     ((tobj1)->tzmode = (tobj2)->tzmode, \
@@ -1766,6 +1767,7 @@ time_s_alloc(VALUE klass) https://github.com/ruby/ruby/blob/trunk/time.c#L1767
     tobj->tzmode = TIME_TZMODE_UNINITIALIZED;
     tobj->tm_got=0;
     tobj->timew = WINT2FIXWV(0);
+    tobj->vtm.zone = Qnil;
 
     return obj;
 }
@@ -3728,7 +3730,7 @@ time_fixoff(VALUE time) https://github.com/ruby/ruby/blob/trunk/time.c#L3730
 {
     struct time_object *tobj;
     struct vtm vtm;
-    VALUE off;
+    VALUE off, zone;
 
     GetTimeval(time, tobj);
     if (TZMODE_FIXOFF_P(tobj)) {
@@ -3746,7 +3748,9 @@ time_fixoff(VALUE time) https://github.com/ruby/ruby/blob/trunk/time.c#L3748
 
     GMTIMEW(tobj->timew, &vtm);
 
+    zone = tobj->vtm.zone;
     tobj->vtm = vtm;
+    tobj->vtm.zone = zone;
     vtm_add_offset(&tobj->vtm, off);
 
     tobj->tm_got = 1;
@@ -4972,7 +4976,6 @@ end_submicro: ; https://github.com/ruby/ruby/blob/trunk/time.c#L4976
 	time_fixoff(time);
     }
     if (!NIL_P(zone)) {
-	if (TZMODE_FIXOFF_P(tobj)) TZMODE_SET_LOCALTIME(tobj);
 	zone = rb_fstring(zone);
 	tobj->vtm.zone = zone;
     }
Index: test/ruby/test_time_tz.rb
===================================================================
--- test/ruby/test_time_tz.rb	(revision 65024)
+++ test/ruby/test_time_tz.rb	(revision 65025)
@@ -546,6 +546,7 @@ module TestTimeTZ::WithTZ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time_tz.rb#L546
     t2 = Marshal.load(Marshal.dump(t))
     assert_equal(t, t2)
     assert_equal(t.utc_offset, t2.utc_offset)
+    assert_equal(t.utc_offset, (t2+1).utc_offset)
   end
 end
 

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

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