Permalink
Browse files

synching with ruby trunk

  • Loading branch information...
1 parent 03e245a commit 8e21278d700b988fbe9c9699fb30ae9063ec9d31 @tenderlove tenderlove committed May 13, 2011
@@ -80,10 +80,10 @@ def tokenize string
def parse_time string
date, time = *(string.split(/[ tT]/, 2))
(yy, m, dd) = date.split('-').map { |x| x.to_i }
- md = time.match(/(\d+:\d+:\d+)(\.\d*)?\s*(Z|[-+]\d+(:\d\d)?)?/)
+ md = time.match(/(\d+:\d+:\d+)(?:\.(\d*))?\s*(Z|[-+]\d+(:\d\d)?)?/)
(hh, mm, ss) = md[1].split(':').map { |x| x.to_i }
- us = (md[2] ? Rational(md[2].sub(/^\./, '0.')) : 0) * 1000000
+ us = (md[2] ? Rational("0.#{md[2]}") : 0) * 1000000
time = Time.utc(yy, m, dd, hh, mm, ss, us)
@@ -297,7 +297,7 @@ def visit_Symbol o
private
def format_time time
if time.utc?
- time.strftime("%Y-%m-%d %H:%M:%S.%9NZ")
+ time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
else
time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")
end
@@ -95,7 +95,7 @@ def test_time
time = Time.utc(2010, 10, 10)
@stream.push({'a' => time })
json = @io.string
- assert_match "{\"a\": \"2010-10-10 00:00:00.000000000Z\"}\n", json
+ assert_match "{\"a\": \"2010-10-10 00:00:00.000000000 Z\"}\n", json
end
def test_datetime
@@ -53,7 +53,7 @@ def test_list_to_json
def test_time
time = Time.utc(2010, 10, 10)
- assert_equal "{\"a\": \"2010-10-10 00:00:00.000000000Z\"}\n",
+ assert_equal "{\"a\": \"2010-10-10 00:00:00.000000000 Z\"}\n",
Psych.to_json({'a' => time })
end
View
@@ -14,6 +14,12 @@ def teardown
Psych.domain_types.clear
end
+ def test_syck_compat
+ time = Time.utc(2010, 10, 10)
+ yaml = Psych.dump time
+ assert_match "2010-10-10 00:00:00.000000000 Z", yaml
+ end
+
# [ruby-core:34969]
def test_regexp_with_n
assert_cycle(Regexp.new('',0,'n'))

0 comments on commit 8e21278

Please sign in to comment.