diff --git a/lib/time.rb b/lib/time.rb index d945e876ae..e227166c47 100644 --- a/lib/time.rb +++ b/lib/time.rb @@ -571,7 +571,7 @@ class Time T (\d\d):(\d\d):(\d\d) (\.\d+)? - (Z|[+-]\d\d:?\d\d)? + (Z|[+-]\d\d(?::?\d\d)?)? \s*\z/ix =~ date year = $1.to_i mon = $2.to_i diff --git a/test/test_time.rb b/test/test_time.rb index d01d74eb52..26a7daaf2a 100644 --- a/test/test_time.rb +++ b/test/test_time.rb @@ -106,6 +106,7 @@ class TestTimeExtension < Test::Unit::TestCase # :nodoc: s = "1996-12-19T16:39:57-08:00" assert_equal(t, Time.__send__(method, s)) assert_equal(t, Time.__send__(method, s.sub(/:(?=00\z)/, ''))) + assert_equal(t, Time.__send__(method, s.sub(/:00\z/, ''))) # There is no way to generate time string with arbitrary timezone. s = "1996-12-20T00:39:57Z" assert_equal(t, Time.__send__(method, s))