mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
time.rb: fix parsing time zone in iso8601
* lib/time.rb (Time.xmlschema): a colon in time zone designator can be omitted. [ruby-core:87277] [Bug #14790] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3e2ff59f10
commit
71fed537ac
2 changed files with 2 additions and 1 deletions
|
@ -571,7 +571,7 @@ class Time
|
||||||
T
|
T
|
||||||
(\d\d):(\d\d):(\d\d)
|
(\d\d):(\d\d):(\d\d)
|
||||||
(\.\d+)?
|
(\.\d+)?
|
||||||
(Z|[+-]\d\d:\d\d)?
|
(Z|[+-]\d\d:?\d\d)?
|
||||||
\s*\z/ix =~ date
|
\s*\z/ix =~ date
|
||||||
year = $1.to_i
|
year = $1.to_i
|
||||||
mon = $2.to_i
|
mon = $2.to_i
|
||||||
|
|
|
@ -105,6 +105,7 @@ class TestTimeExtension < Test::Unit::TestCase # :nodoc:
|
||||||
t = Time.utc(1996, 12, 20, 0, 39, 57)
|
t = Time.utc(1996, 12, 20, 0, 39, 57)
|
||||||
s = "1996-12-19T16:39:57-08:00"
|
s = "1996-12-19T16:39:57-08:00"
|
||||||
assert_equal(t, Time.__send__(method, s))
|
assert_equal(t, Time.__send__(method, s))
|
||||||
|
assert_equal(t, Time.__send__(method, s.sub(/:(?=00\z)/, '')))
|
||||||
# There is no way to generate time string with arbitrary timezone.
|
# There is no way to generate time string with arbitrary timezone.
|
||||||
s = "1996-12-20T00:39:57Z"
|
s = "1996-12-20T00:39:57Z"
|
||||||
assert_equal(t, Time.__send__(method, s))
|
assert_equal(t, Time.__send__(method, s))
|
||||||
|
|
Loading…
Reference in a new issue