ruby-changes:19394
From: tenderlove <ko1@a...>
Date: Thu, 5 May 2011 08:08:09 +0900 (JST)
Subject: [ruby-changes:19394] Ruby:r31434 (trunk): fix capture to avoid doing a sub on the useconds when parsing dates
tenderlove 2011-05-05 08:07:58 +0900 (Thu, 05 May 2011) New Revision: 31434 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31434 Log: fix capture to avoid doing a sub on the useconds when parsing dates Modified files: trunk/ext/psych/lib/psych/scalar_scanner.rb Index: ext/psych/lib/psych/scalar_scanner.rb =================================================================== --- ext/psych/lib/psych/scalar_scanner.rb (revision 31433) +++ ext/psych/lib/psych/scalar_scanner.rb (revision 31434) @@ -80,10 +80,10 @@ 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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/