* lib/time.rb (Time.xmlschema): don't accept decimal dot without
fractional digits. fractional digits handling simplified. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6fc17f1f7b
commit
05093ae437
@ -1,3 +1,8 @@
|
|||||||
|
Fri Jun 13 18:08:10 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* lib/time.rb (Time.xmlschema): don't accept decimal dot without
|
||||||
|
fractional digits. fractional digits handling simplified.
|
||||||
|
|
||||||
Fri Jun 13 17:20:40 2008 wanabe <s.wanabe@gmail.com>
|
Fri Jun 13 17:20:40 2008 wanabe <s.wanabe@gmail.com>
|
||||||
|
|
||||||
* complex.c (string_to_c_internal): save and restore backref.
|
* complex.c (string_to_c_internal): save and restore backref.
|
||||||
|
@ -374,7 +374,7 @@ class Time
|
|||||||
(-?\d+)-(\d\d)-(\d\d)
|
(-?\d+)-(\d\d)-(\d\d)
|
||||||
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
|
||||||
@ -385,7 +385,7 @@ class Time
|
|||||||
sec = $6.to_i
|
sec = $6.to_i
|
||||||
usec = 0
|
usec = 0
|
||||||
if $7
|
if $7
|
||||||
usec = Rational(($7[1..-1] + '000000000')[0,9].to_i, 1000)
|
usec = Rational($7) * 1000000
|
||||||
end
|
end
|
||||||
if $8
|
if $8
|
||||||
zone = $8
|
zone = $8
|
||||||
@ -624,6 +624,7 @@ if __FILE__ == $0
|
|||||||
Time.xmlschema("2000-01-12T12:13:14Z"))
|
Time.xmlschema("2000-01-12T12:13:14Z"))
|
||||||
assert_equal(Time.utc(2001, 4, 17, 19, 23, 17, 300000),
|
assert_equal(Time.utc(2001, 4, 17, 19, 23, 17, 300000),
|
||||||
Time.xmlschema("2001-04-17T19:23:17.3Z"))
|
Time.xmlschema("2001-04-17T19:23:17.3Z"))
|
||||||
|
assert_raise(ArgumentError) { Time.xmlschema("2000-01-01T00:00:00.+00:00") }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_encode_xmlschema
|
def test_encode_xmlschema
|
||||||
@ -812,6 +813,10 @@ if __FILE__ == $0
|
|||||||
assert_equal(t, Time.xmlschema("1998-12-31T23:00:00-01:00"))
|
assert_equal(t, Time.xmlschema("1998-12-31T23:00:00-01:00"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_xmlschema_fraction
|
||||||
|
assert_equal(500000, Time.xmlschema("2000-01-01T00:00:00.5+00:00").tv_usec)
|
||||||
|
end
|
||||||
|
|
||||||
def test_ruby_talk_152866
|
def test_ruby_talk_152866
|
||||||
t = Time::xmlschema('2005-08-30T22:48:00-07:00')
|
t = Time::xmlschema('2005-08-30T22:48:00-07:00')
|
||||||
assert_equal(31, t.day)
|
assert_equal(31, t.day)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user