ruby-changes:65778
From: usa <ko1@a...>
Date: Mon, 5 Apr 2021 09:17:39 +0900 (JST)
Subject: [ruby-changes:65778] 082b0acffb (ruby_2_6): merge revision(s) 276f6a225d18561cbe5282b798cb4e416c66079f,95bef7b69a6fb42687a6200b338060be307259f5: [Backport #17352]
https://git.ruby-lang.org/ruby.git/commit/?id=082b0acffb From 082b0acffb9eb93c350b5b04fc59509fa9329786 Mon Sep 17 00:00:00 2001 From: usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> Date: Mon, 5 Apr 2021 00:17:28 +0000 Subject: merge revision(s) 276f6a225d18561cbe5282b798cb4e416c66079f,95bef7b69a6fb42687a6200b338060be307259f5: [Backport #17352] Don't double fractional seconds when passing timezone object to Time.new I found that fractional seconds were doubled when using the timezone feature of Time in Sequel's named_timezones extension (which uses TZInfo for the timezone object), and traced the problem to this code. There is no subsecx being modified in the utc_to_local call below this, and I'm not sure why you would want to add in the fractional seconds unless you assumed the timezone conversion would drop the existing fractional seconds (TZInfo doesn't drop fractional seconds). Subsecond of Time::tm should be 0 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_time_tz.rb | 10 ++++++++++ time.c | 1 + version.h | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb index f91cd66..9bba30e 100644 --- a/test/ruby/test_time_tz.rb +++ b/test/ruby/test_time_tz.rb @@ -659,6 +659,16 @@ else https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time_tz.rb#L659 @tz ||= TZInfo::Timezone.get(tzname) end end + + def test_fractional_second + x = Object.new + def x.local_to_utc(t); t + 8*3600; end + def x.utc_to_local(t); t - 8*3600; end + + t1 = Time.new(2020,11,11,12,13,14.124r, '-08:00') + t2 = Time.new(2020,11,11,12,13,14.124r, x) + assert_equal(t1, t2) + end end begin diff --git a/time.c b/time.c index 2ce9522..228100a 100644 --- a/time.c +++ b/time.c @@ -5152,6 +5152,7 @@ tm_from_time(VALUE klass, VALUE time) https://github.com/ruby/ruby/blob/trunk/time.c#L5152 ttm = DATA_PTR(tm); v = &vtm; GMTIMEW(ttm->timew = tobj->timew, v); + ttm->timew = wsub(ttm->timew, v->subsecx); v->subsecx = INT2FIX(0); v->zone = Qnil; ttm->vtm = *v; diff --git a/version.h b/version.h index 382b1c0..69b074f 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-04-05" -#define RUBY_PATCHLEVEL 193 +#define RUBY_PATCHLEVEL 194 #define RUBY_RELEASE_YEAR 2021 #define RUBY_RELEASE_MONTH 4 -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/