summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-05-13 15:26:59 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-05-13 15:26:59 -0700
commit8e21278d700b988fbe9c9699fb30ae9063ec9d31 (patch)
treeabc14920f2aec801c7fc61968822744daede71de /lib
parent03e245adc7d73c3538471933bafba57972b9efcb (diff)
downloadpsych-8e21278d700b988fbe9c9699fb30ae9063ec9d31.zip
synching with ruby trunk
Diffstat (limited to 'lib')
-rw-r--r--lib/psych/scalar_scanner.rb4
-rw-r--r--lib/psych/visitors/yaml_tree.rb2
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/psych/scalar_scanner.rb b/lib/psych/scalar_scanner.rb
index f7aaea7..29d66ee 100644
--- a/lib/psych/scalar_scanner.rb
+++ b/lib/psych/scalar_scanner.rb
@@ -80,10 +80,10 @@ module Psych
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)
diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb
index 84ebc90..6f90377 100644
--- a/lib/psych/visitors/yaml_tree.rb
+++ b/lib/psych/visitors/yaml_tree.rb
@@ -297,7 +297,7 @@ module Psych
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