diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2012-03-19 10:01:54 -0700 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2012-03-19 10:01:54 -0700 |
commit | 09d884cd2cb8f49f0899864cd42649a3bf403872 (patch) | |
tree | b06368e88fc4c315fc7c6e39bf2d61cda2cb6053 /actionpack/lib | |
parent | 9c748f3961816d10b4a7be7b66a70b3b4bcd52cf (diff) | |
parent | d2d2fc0834503bf377d9d7adb136b16856ae49d5 (diff) | |
download | rails-09d884cd2cb8f49f0899864cd42649a3bf403872.tar.gz rails-09d884cd2cb8f49f0899864cd42649a3bf403872.tar.bz2 rails-09d884cd2cb8f49f0899864cd42649a3bf403872.zip |
Merge pull request #5503 from jeyb/leap_day_time_date_time_selector
Fixes issue #5222: DateTimeSelector builds invalid dates on leap days
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/date_helper.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index ee9f0da9b8..be67042999 100644 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -674,9 +674,9 @@ module ActionView @options[:discard_minute] ||= true if @options[:discard_hour] @options[:discard_second] ||= true unless @options[:include_seconds] && !@options[:discard_minute] - # If the day is hidden and the month is visible, the day should be set to the 1st so all month choices are - # valid (otherwise it could be 31 and February wouldn't be a valid date) - if @datetime && @options[:discard_day] && !@options[:discard_month] + # If the day is hidden, the day should be set to the 1st so all month and year choices are valid. Otherwise, + # February 31st or February 29th, 2011 can be selected, which are invalid. + if @datetime && @options[:discard_day] @datetime = @datetime.change(:day => 1) end @@ -701,9 +701,9 @@ module ActionView @options[:discard_month] ||= true unless order.include?(:month) @options[:discard_day] ||= true if @options[:discard_month] || !order.include?(:day) - # If the day is hidden and the month is visible, the day should be set to the 1st so all month choices are - # valid (otherwise it could be 31 and February wouldn't be a valid date) - if @datetime && @options[:discard_day] && !@options[:discard_month] + # If the day is hidden, the day should be set to the 1st so all month and year choices are valid. Otherwise, + # February 31st or February 29th, 2011 can be selected, which are invalid. + if @datetime && @options[:discard_day] @datetime = @datetime.change(:day => 1) end |