summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2024-04-07 14:53:48 +0900
committernagachika <nagachika@ruby-lang.org>2024-04-07 14:53:48 +0900
commite6bf38a6e7fbae0097fdf51e3c752820a2c58ae4 (patch)
treeb5374abfee1d8dd700237ff3770db8402ca50582 /test/ruby
parentbaa5bc16c17e3b4dac7b590ed5d6b7e705535e15 (diff)
merge revision(s) d3279a0c11ca45ca85027e7eb74dc4aac52c478b: [Backport #20327]
[Bug #20327] Do not count subsecond to calculate UTC offset Assume that there will never be any time zones with UTC offsets that are subseconds. Historically, UTC offset has only been used down to the second. --- test/ruby/test_time_tz.rb | 8 ++++++++ time.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-)
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_time_tz.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb
index 531d76b040..f66cd9bec2 100644
--- a/test/ruby/test_time_tz.rb
+++ b/test/ruby/test_time_tz.rb
@@ -695,6 +695,13 @@ module TestTimeTZ::WithTZ
assert_equal(t.dst?, t2.dst?)
end
+ def subtest_fractional_second(time_class, tz, tzarg, tzname, abbr, utc_offset)
+ t = time_class.new(2024, 1, 1, 23, 59, 59.9r, tzarg)
+ assert_equal(utc_offset[t.dst? ? 1 : 0], t.utc_offset)
+ t = time_class.new(2024, 7, 1, 23, 59, 59.9r, tzarg)
+ assert_equal(utc_offset[t.dst? ? 1 : 0], t.utc_offset)
+ end
+
def test_invalid_zone
make_timezone("INVALID", "INV", 0)
rescue => e
@@ -719,6 +726,7 @@ module TestTimeTZ::WithTZ
"Asia/Tokyo" => ["JST", +9*3600],
"America/Los_Angeles" => ["PST", -8*3600, "PDT", -7*3600],
"Africa/Ndjamena" => ["WAT", +1*3600],
+ "Etc/UTC" => ["UTC", 0],
}
def make_timezone(tzname, abbr, utc_offset, abbr2 = nil, utc_offset2 = nil)