summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorS.H <gamelinks007@gmail.com>2020-07-24 20:17:31 +0900
committerGitHub <noreply@github.com>2020-07-24 20:17:31 +0900
commit2735da2039b9e441e41b11b606ba362db350a658 (patch)
tree0a87482694977d200fd88523d04c57dba9c84dde
parent922fe4da3f6a2ecef5f89e6b7dbb760b7afe2314 (diff)
Fix Time#to_a behavior with timezone [Bug #17046]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3355 Merged-By: nobu <nobu@ruby-lang.org>
-rw-r--r--test/ruby/test_time_tz.rb6
-rw-r--r--time.c2
2 files changed, 7 insertions, 1 deletions
diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb
index 4cf1fcbf4d..c9c2b77115 100644
--- a/test/ruby/test_time_tz.rb
+++ b/test/ruby/test_time_tz.rb
@@ -661,6 +661,12 @@ module TestTimeTZ::WithTZ
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 f00e0cddff..70725b7fe0 100644
--- a/time.c
+++ b/time.c
@@ -4867,7 +4867,7 @@ time_to_a(VALUE time)
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),