summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-19 02:56:39 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-19 02:56:39 +0000
commitf75b676cc4f5411c4c1aa8cc9cb48d5dd665af6f ()
tree019d7adb954e3e2ae194070ab0046637280db877 /lib
parent595d057e60a9fe6550500dd17535e22134f0d63f (diff)
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
-rw-r--r--lib/rdoc/parser/changelog.rb8
-rw-r--r--lib/time.rb3
2 files changed, 8 insertions, 3 deletions
@@ -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
time, = entry_name.split ' ', 2
- time = Time.parse time
rescue ArgumentError
- entry_name = nil
end
entry_body = []
@@ -214,7 +214,8 @@ class Time
if o != 0 then hour += o; o, hour = hour.divmod(24); off += o end
if off != 0
day += off
- if month_days(year, mon) < day
mon += 1
if 12 < mon
mon = 1