From ce2e7368d73b762a86690fe3531e0754301299be Mon Sep 17 00:00:00 2001 From: tenderlove Date: Mon, 5 Jul 2010 03:33:56 +0000 Subject: * ext/psych/lib/psych/scalar_scanner.rb (parse_string): support timezones that are not one hour off. [ruby-core:31023] * ext/psych/lib/psych/visitors/yaml_tree.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/psych/lib/psych/scalar_scanner.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ext/psych/lib/psych/scalar_scanner.rb') diff --git a/ext/psych/lib/psych/scalar_scanner.rb b/ext/psych/lib/psych/scalar_scanner.rb index e65651a740..e2aef65bda 100644 --- a/ext/psych/lib/psych/scalar_scanner.rb +++ b/ext/psych/lib/psych/scalar_scanner.rb @@ -88,9 +88,11 @@ module Psych time = Time.utc(yy, m, dd, hh, mm, ss, us) return time if 'Z' == md[3] + return Time.at(time.to_i, us) unless md[3] - tz = md[3] ? Integer(md[3].split(':').first.sub(/([-+])0/, '\1')) : 0 - Time.at((time - (tz * 3600)).to_i, us) + tz = md[3].split(':').map { |digit| Integer(digit.sub(/([-+])0/, '\1')) } + offset = tz.first * 3600 + ((tz[1] || 0) * 60) + Time.at((time - offset).to_i, us) end end end -- cgit v1.2.3