aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_time.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-20 01:03:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-20 01:03:18 +0000
commit90048176ccde574cb315437faecf468f45370dfd (patch)
tree07b8b3c2e4236429e5ac1764211db8454420599c /test/test_time.rb
parentf16f0441d681dd9d2e09631fd068268a63fe1f3b (diff)
downloadruby-90048176ccde574cb315437faecf468f45370dfd.tar.gz
Make Time.parse respect timezone offset seconds
DateTime.parse handles them correctly, and DateTime.parse.to_time results in the correct time. Time.parse doesn't handle them correctly because Time.zone_offset uses a different regexp that only considers hours and minutes, not seconds. [ruby-core:83400] [Bug #14034] From: Jeremy Evans <code@jeremyevans.net> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_time.rb')
-rw-r--r--test/test_time.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/test_time.rb b/test/test_time.rb
index 398ab7279b..9d7c976abf 100644
--- a/test/test_time.rb
+++ b/test/test_time.rb
@@ -343,6 +343,13 @@ class TestTimeExtension < Test::Unit::TestCase # :nodoc:
Time.parse("2000-01-01T00:00:00+11:00", nil))
end
+ def test_parse_offset_hour_minute_second
+ t = Time.at(-100000000000).utc
+ assert_equal(t, Time.parse("1200-02-15 BC 14:13:20-00"))
+ assert_equal(t, Time.parse("1200-02-15 BC 14:13:20-00:00"))
+ assert_equal(t, Time.parse("1200-02-15 BC 14:13:20-00:00:00"))
+ end
+
def test_parse_leap_second
t = Time.utc(1998,12,31,23,59,59)
assert_equal(t, Time.parse("Thu Dec 31 23:59:59 UTC 1998"))