ruby-changes:54565
From: nagachika <ko1@a...>
Date: Thu, 10 Jan 2019 23:46:46 +0900 (JST)
Subject: [ruby-changes:54565] nagachika:r66780 (ruby_2_5): merge revision(s) 63823, 63839: [Backport #14890]
nagachika 2019-01-10 23:46:41 +0900 (Thu, 10 Jan 2019) New Revision: 66780 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66780 Log: merge revision(s) 63823,63839: [Backport #14890] time.c: [DOC] Time#localtime * time.c: state that Time#localtime does nothing when nothing changes. [ruby-core:87675] [Bug #14880] skip test_localtime_zone if force_tz_test is false For example Solaris https://rubyci.org/logs/rubyci.s3.amazonaws.com/unstable10x/ruby-trunk/log/20180703T091803Z.fail.html.gz Modified directories: branches/ruby_2_5/ Modified files: branches/ruby_2_5/spec/ruby/core/time/localtime_spec.rb branches/ruby_2_5/test/ruby/test_time_tz.rb branches/ruby_2_5/time.c branches/ruby_2_5/version.h Index: ruby_2_5/test/ruby/test_time_tz.rb =================================================================== --- ruby_2_5/test/ruby/test_time_tz.rb (revision 66779) +++ ruby_2_5/test/ruby/test_time_tz.rb (revision 66780) @@ -107,6 +107,18 @@ class TestTimeTZ < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_5/test/ruby/test_time_tz.rb#L107 assert_equal(expected, real, m) end + def test_localtime_zone + t = with_tz("America/Los_Angeles") { + Time.local(2000, 1, 1) + } + skip "force_tz_test is false on this environment" unless t + z1 = t.zone + z2 = with_tz(tz="Asia/Singapore") { + t.localtime.zone + } + assert_equal(z2, z1) + end + def test_america_los_angeles with_tz(tz="America/Los_Angeles") { assert_time_constructor(tz, "2007-03-11 03:00:00 -0700", :local, [2007,3,11,2,0,0]) Index: ruby_2_5/version.h =================================================================== --- ruby_2_5/version.h (revision 66779) +++ ruby_2_5/version.h (revision 66780) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/version.h#L1 #define RUBY_VERSION "2.5.4" #define RUBY_RELEASE_DATE "2019-01-10" -#define RUBY_PATCHLEVEL 126 +#define RUBY_PATCHLEVEL 127 #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 1 Index: ruby_2_5/time.c =================================================================== --- ruby_2_5/time.c (revision 66779) +++ ruby_2_5/time.c (revision 66780) @@ -3410,6 +3410,9 @@ time_localtime(VALUE time) https://github.com/ruby/ruby/blob/trunk/ruby_2_5/time.c#L3410 * * t.localtime("+09:00") #=> 2000-01-02 05:15:01 +0900 * t.utc? #=> false + * + * If +utc_offset+ is not given and _time_ is local time, just return + * the receiver. */ static VALUE Index: ruby_2_5/spec/ruby/core/time/localtime_spec.rb =================================================================== --- ruby_2_5/spec/ruby/core/time/localtime_spec.rb (revision 66779) +++ ruby_2_5/spec/ruby/core/time/localtime_spec.rb (revision 66780) @@ -90,6 +90,19 @@ describe "Time#localtime" do https://github.com/ruby/ruby/blob/trunk/ruby_2_5/spec/ruby/core/time/localtime_spec.rb#L90 t.utc_offset.should == -18000 end + + it "does nothing if already in a local time zone" do + time = with_timezone("America/New_York") do + break Time.new(2005, 2, 27, 22, 50, 0) + end + zone = time.zone + + with_timezone("Europe/Amsterdam") do + time.localtime + end + + time.zone.should == zone + end end describe "with an argument that responds to #to_str" do Index: ruby_2_5 =================================================================== --- ruby_2_5 (revision 66779) +++ ruby_2_5 (revision 66780) Property changes on: ruby_2_5 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r63823,63839 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/