1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fix Time#to_a behavior with timezone [Bug #17046]

This commit is contained in:
S.H 2020-07-24 20:17:31 +09:00 committed by GitHub
parent 922fe4da3f
commit 2735da2039
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2020-07-24 20:17:55 +09:00
Merged: https://github.com/ruby/ruby/pull/3355

Merged-By: nobu <nobu@ruby-lang.org>
2 changed files with 7 additions and 1 deletions

View file

@ -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))

2
time.c
View file

@ -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),