From d3802d719ce37f023cf5c076ca29c1ddde5c51b4 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Wed, 4 May 2011 23:07:58 +0000 Subject: 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 --- ext/psych/lib/psych/scalar_scanner.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/psych/lib/psych/scalar_scanner.rb b/ext/psych/lib/psych/scalar_scanner.rb index f7aaea7435..29d66ee4cc 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) -- cgit v1.2.3