ruby-changes:62389
From: S.H <ko1@a...>
Date: Fri, 24 Jul 2020 20:17:51 +0900 (JST)
Subject: [ruby-changes:62389] 2735da2039 (master): Fix Time#to_a behavior with timezone [Bug #17046]
https://git.ruby-lang.org/ruby.git/commit/?id=2735da2039 From 2735da2039b9e441e41b11b606ba362db350a658 Mon Sep 17 00:00:00 2001 From: "S.H" <gamelinks007@g...> Date: Fri, 24 Jul 2020 20:17:31 +0900 Subject: Fix Time#to_a behavior with timezone [Bug #17046] diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb index 4cf1fcb..c9c2b77 100644 --- a/test/ruby/test_time_tz.rb +++ b/test/ruby/test_time_tz.rb @@ -661,6 +661,12 @@ module TestTimeTZ::WithTZ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time_tz.rb#L661 assert_equal(utc, t.to_i) end + def subtest_to_a(time_class, tz, tzarg, tzname, abbr, utc_offset) + t = time_class.new(2018, 9, 1, 12, 0, 0, tzarg) + ary = t.to_a + assert_equal(ary, [t.sec, t.min, t.hour, t.mday, t.mon, t.year, t.wday, t.yday, t.isdst, t.zone]) + end + def subtest_marshal(time_class, tz, tzarg, tzname, abbr, utc_offset) t = time_class.new(2018, 9, 1, 12, 0, 0, tzarg) t2 = Marshal.load(Marshal.dump(t)) diff --git a/time.c b/time.c index f00e0cd..70725b7 100644 --- a/time.c +++ b/time.c @@ -4867,7 +4867,7 @@ time_to_a(VALUE time) https://github.com/ruby/ruby/blob/trunk/time.c#L4867 struct time_object *tobj; GetTimeval(time, tobj); - MAKE_TM(time, tobj); + MAKE_TM_ENSURE(time, tobj, tobj->vtm.yday != 0); return rb_ary_new3(10, INT2FIX(tobj->vtm.sec), INT2FIX(tobj->vtm.min), -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/