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

ruby-changes:65379

From: usa <ko1@a...>
Date: Tue, 2 Mar 2021 20:44:15 +0900 (JST)
Subject: [ruby-changes:65379] 0fe5d0f60d (ruby_2_6): merge revision(s) 99a9c3fe: [Backport #17024]

https://git.ruby-lang.org/ruby.git/commit/?id=0fe5d0f60d

From 0fe5d0f60df11203be9a5ace1ead2895759f456a Mon Sep 17 00:00:00 2001
From: usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date: Tue, 2 Mar 2021 11:44:02 +0000
Subject: merge revision(s) 99a9c3fe: [Backport #17024]

	Fixed yday and wday with timezone [Bug #17024]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
---
 test/ruby/test_time_tz.rb |  2 ++
 time.c                    | 13 +++++++++----
 version.h                 |  2 +-
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb
index 21ac667..f91cd66 100644
--- a/test/ruby/test_time_tz.rb
+++ b/test/ruby/test_time_tz.rb
@@ -548,6 +548,8 @@ module TestTimeTZ::WithTZ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time_tz.rb#L548
     m, s = (4000-utc_offset).divmod(60)
     h, m = m.divmod(60)
     assert_equal(time_class.utc(2018, 9, 1, 12+h, m, s), t)
+    assert_equal(6, t.wday)
+    assert_equal(244, t.yday)
   end
 
   def subtest_at(time_class, tz, tzarg, tzname, abbr, utc_offset)
diff --git a/time.c b/time.c
index 75db554..2ce9522 100644
--- a/time.c
+++ b/time.c
@@ -4322,14 +4322,15 @@ time_wday(VALUE time) https://github.com/ruby/ruby/blob/trunk/time.c#L4322
 
     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; \
 }
 
 /*
@@ -4461,6 +4462,10 @@ time_yday(VALUE time) https://github.com/ruby/ruby/blob/trunk/time.c#L4462
 
     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 616e6f3..a827dae 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L1
 #define RUBY_VERSION "2.6.7"
 #define RUBY_RELEASE_DATE "2021-03-02"
-#define RUBY_PATCHLEVEL 170
+#define RUBY_PATCHLEVEL 171
 
 #define RUBY_RELEASE_YEAR 2021
 #define RUBY_RELEASE_MONTH 3
-- 
cgit v1.1


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

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