summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-28 23:31:33 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-28 23:31:33 +0000
commitaed90c7cae00669436c001cdc747bb0ed93c1e31 (patch)
tree0e9327dcbec41ec7bf9d5929adf2f759d12b82f0
parentcb5c87b727ff957bbb26f1f090f8440635e27a1a (diff)
merges r30957 from trunk into ruby_1_9_2.
-- * ext/psych/lib/psych/scalar_scanner.rb: fix parsing timezone's whose whose format is (+/-)hhmm. Thanks Gonçalo Silva! * test/psych/test_scalar_scanner.rb: test for bug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@31769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--ext/psych/lib/psych/scalar_scanner.rb2
-rw-r--r--test/psych/test_scalar_scanner.rb23
-rw-r--r--version.h2
4 files changed, 20 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 808a3663fd..e23504705f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat Feb 26 07:10:05 2011 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * ext/psych/lib/psych/scalar_scanner.rb: fix parsing timezone's whose
+ whose format is (+/-)hhmm. Thanks Gonçalo Silva!
+
+ * test/psych/test_scalar_scanner.rb: test for bug.
+
Mon Feb 28 13:02:15 2011 Danial Pearce <github@tigris.id.au>
* lib/tempfile.rb: Fix example file paths in docs for tempfile.
diff --git a/ext/psych/lib/psych/scalar_scanner.rb b/ext/psych/lib/psych/scalar_scanner.rb
index e1e59d37e3..f7aaea7435 100644
--- a/ext/psych/lib/psych/scalar_scanner.rb
+++ b/ext/psych/lib/psych/scalar_scanner.rb
@@ -90,7 +90,7 @@ module Psych
return time if 'Z' == md[3]
return Time.at(time.to_i, us) unless md[3]
- tz = md[3].split(':').map { |digit| Integer(digit, 10) }
+ tz = md[3].match(/^([+\-]?\d{1,2})\:?(\d{1,2})?$/)[1..-1].compact.map { |digit| Integer(digit, 10) }
offset = tz.first * 3600
if offset < 0
diff --git a/test/psych/test_scalar_scanner.rb b/test/psych/test_scalar_scanner.rb
index 69dc127236..df54eb1eed 100644
--- a/test/psych/test_scalar_scanner.rb
+++ b/test/psych/test_scalar_scanner.rb
@@ -2,18 +2,6 @@ require_relative 'helper'
module Psych
class TestScalarScanner < TestCase
- def test_scan_time
- [ '2001-12-15T02:59:43.1Z',
- '2001-12-14t21:59:43.10-05:00',
- '2001-12-14 21:59:43.10 -5',
- '2010-01-06 00:00:00 -08:00',
- '2001-12-15 2:59:43.10',
- ].each do |time|
- ss = Psych::ScalarScanner.new
- assert_instance_of Time, ss.tokenize(time)
- end
- end
-
attr_reader :ss
def setup
@@ -21,6 +9,17 @@ module Psych
@ss = Psych::ScalarScanner.new
end
+ def test_scan_time
+ { '2001-12-15T02:59:43.1Z' => Time.utc(2001, 12, 15, 02, 59, 43, 100000),
+ '2001-12-14t21:59:43.10-05:00' => Time.utc(2001, 12, 15, 02, 59, 43, 100000),
+ '2001-12-14 21:59:43.10 -5' => Time.utc(2001, 12, 15, 02, 59, 43, 100000),
+ '2001-12-15 2:59:43.10' => Time.utc(2001, 12, 15, 02, 59, 43, 100000),
+ '2011-02-24 11:17:06 -0800' => Time.utc(2011, 02, 24, 19, 17, 06)
+ }.each do |time_str, time|
+ assert_equal time, @ss.tokenize(time_str)
+ end
+ end
+
def test_scan_date
date = '1980-12-16'
token = @ss.tokenize date
diff --git a/version.h b/version.h
index 5839367c57..705040392f 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.2"
-#define RUBY_PATCHLEVEL 207
+#define RUBY_PATCHLEVEL 208
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 1