summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-04 23:07:58 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-04 23:07:58 +0000
commitd3802d719ce37f023cf5c076ca29c1ddde5c51b4 (patch)
tree90570f8853d02b2be0a208ef5fe53f6bdeb49819 /ext
parentf5b0f04d2ae2fdbf94f0a061a40693d84a863e0e (diff)
fix capture to avoid doing a sub on the useconds when parsing dates
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/psych/lib/psych/scalar_scanner.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/psych/lib/psych/scalar_scanner.rb b/ext/psych/lib/psych/scalar_scanner.rb
index f7aaea74350..29d66ee4cc8 100644
--- a/ext/psych/lib/psych/scalar_scanner.rb
+++ b/ext/psych/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)