summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
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)