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

ruby-changes:62366

From: nagachika <ko1@a...>
Date: Thu, 23 Jul 2020 11:33:27 +0900 (JST)
Subject: [ruby-changes:62366] 4be9bf1f67 (ruby_2_7): merge revision(s) 99a9c3fe2eaab8157765d792dc871da6daea0327: [Backport #17024]

https://git.ruby-lang.org/ruby.git/commit/?id=4be9bf1f67

From 4be9bf1f67b997fc519625d56a93b8a68a70d124 Mon Sep 17 00:00:00 2001
From: nagachika <nagachika@r...>
Date: Thu, 23 Jul 2020 11:33:11 +0900
Subject: merge revision(s) 99a9c3fe2eaab8157765d792dc871da6daea0327: [Backport
 #17024]

	Fixed yday and wday with timezone [Bug #17024]

diff --git a/spec/ruby/core/time/new_spec.rb b/spec/ruby/core/time/new_spec.rb
index a5cfa2a..064e03f 100644
--- a/spec/ruby/core/time/new_spec.rb
+++ b/spec/ruby/core/time/new_spec.rb
@@ -121,7 +121,7 @@ describe "Time.new with a utc_offset argument" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/time/new_spec.rb#L121
   end
 end
 
-ruby_version_is "2.6" do
+ruby_version_is "2.7" do
   describe "Time.new with a timezone argument" do
     it "returns a Time in the timezone" do
       zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
@@ -129,6 +129,10 @@ ruby_version_is "2.6" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/time/new_spec.rb#L129
 
       time.zone.should == zone
       time.utc_offset.should == 5*3600+30*60
+      ruby_version_is "2.7" do
+        time.wday.should == 6
+        time.yday.should == 1
+      end
     end
 
     it "accepts timezone argument that must have #local_to_utc and #utc_to_local methods" do
diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb
index 83482ea..7f0a306 100644
--- a/test/ruby/test_time_tz.rb
+++ b/test/ruby/test_time_tz.rb
@@ -608,6 +608,8 @@ module TestTimeTZ::WithTZ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time_tz.rb#L608
     assert_equal([2018, 9, 1, 12, 0, 0, tz], [t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.zone])
     h, m = (-utc_offset / 60).divmod(60)
     assert_equal(time_class.utc(2018, 9, 1, 12+h, m, 0).to_i, t.to_i)
+    assert_equal(6, t.wday)
+    assert_equal(244, t.yday)
   end
 
   def subtest_now(time_class, tz, tzarg, tzname, abbr, utc_offset)
diff --git a/time.c b/time.c
index d71d43e..d76e015 100644
--- a/time.c
+++ b/time.c
@@ -4558,14 +4558,15 @@ time_wday(VALUE time) https://github.com/ruby/ruby/blob/trunk/time.c#L4558
 
     GetTimeval(time, tobj);
     MAKE_TM(time, tobj);
+    if (tobj->vtm.wday == VTM_WDAY_INITVAL) {
+        VALUE zone = tobj->vtm.zone;
+        if (!NIL_P(zone)) zone_localtime(zone, time);
+    }
     return INT2FIX((int)tobj->vtm.wday);
 }
 
 #define wday_p(n) {\
-    struct time_object *tobj;\
-    GetTimeval(time, tobj);\
-    MAKE_TM(time, tobj);\
-    return (tobj->vtm.wday == (n)) ? Qtrue : Qfalse;\
+    return (time_wday(time) == INT2FIX(n)) ? Qtrue : Qfalse; \
 }
 
 /*
@@ -4697,6 +4698,10 @@ time_yday(VALUE time) https://github.com/ruby/ruby/blob/trunk/time.c#L4698
 
     GetTimeval(time, tobj);
     MAKE_TM(time, tobj);
+    if (tobj->vtm.yday == 0) {
+        VALUE zone = tobj->vtm.zone;
+        if (!NIL_P(zone)) zone_localtime(zone, time);
+    }
     return INT2FIX(tobj->vtm.yday);
 }
 
diff --git a/version.h b/version.h
index 7ff1cd9..15007f2 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L2
 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
 #define RUBY_VERSION_TEENY 1
 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 99
+#define RUBY_PATCHLEVEL 100
 
 #define RUBY_RELEASE_YEAR 2020
 #define RUBY_RELEASE_MONTH 7
-- 
cgit v0.10.2


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

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