summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_time_tz.rb10
-rw-r--r--time.c1
-rw-r--r--version.h2
3 files changed, 12 insertions, 1 deletions
diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb
index 7f0a306783..5ee12e4dbd 100644
--- a/test/ruby/test_time_tz.rb
+++ b/test/ruby/test_time_tz.rb
@@ -749,6 +749,16 @@ class TestTimeTZ::DummyTZ < Test::Unit::TestCase
def self.make_timezone(tzname, abbr, utc_offset, abbr2 = nil, utc_offset2 = nil)
TestTimeTZ::TZ.new(tzname, abbr, utc_offset, abbr2, utc_offset2)
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 5c252adee1..e1d91cad75 100644
--- a/time.c
+++ b/time.c
@@ -5470,6 +5470,7 @@ tm_from_time(VALUE klass, VALUE time)
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 c0e2f3f081..fc74d072af 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 3
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 169
+#define RUBY_PATCHLEVEL 170
#define RUBY_RELEASE_YEAR 2021
#define RUBY_RELEASE_MONTH 3