From f75b676cc4f5411c4c1aa8cc9cb48d5dd665af6f Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 19 Jul 2014 02:56:39 +0000 Subject: Fix `Time.parse` for out of range arguments with an offset * lib/time.rb (Time#apply_offset): Guards against a `nil` return value from `Time.month_days` when offsetting date. Out of range values are then caught when `Time.utc` is called (as usual). Previously a `nil` return value from `Time.month_days` would have the `<` operator called on it, and raise `NoMethodError`. [fix GH-667] * lib/rdoc/parser/changelog.rb (RDoc#parse_entries): fix dirty hack. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rdoc/parser/changelog.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/rdoc/parser') diff --git a/lib/rdoc/parser/changelog.rb b/lib/rdoc/parser/changelog.rb index 782d8f09bf..75fcaaad85 100644 --- a/lib/rdoc/parser/changelog.rb +++ b/lib/rdoc/parser/changelog.rb @@ -145,10 +145,14 @@ class RDoc::Parser::ChangeLog < RDoc::Parser # HACK Ruby 1.8 does not raise ArgumentError for Time.parse "Other" entry_name = nil unless entry_name =~ /#{time.year}/ rescue NoMethodError + # HACK Ruby 2.1.2 and earlier raises NoMethodError if time part is absent time, = entry_name.split ' ', 2 - time = Time.parse time rescue ArgumentError - entry_name = nil + if /out of range/ =~ $!.message + time = Time.parse(entry_name.split(' ', 2)[0]) rescue entry_name = nil + else + entry_name = nil + end end entry_body = [] -- cgit v1.2.3