Permalink
Browse files

Fixed include_blank for select_hour/minute/second #527 [edward@debian…

….org]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1055 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 52e5d74 commit 7d09b8d723e7d8d0d2b913573ecd404a84305397 @dhh dhh committed Apr 2, 2005
View
@@ -1,5 +1,7 @@
*SVN*
+* Fixed include_blank for select_hour/minute/second #527 [edward@debian.org]
+
* Improved the message display on the exception handler pages #963 [Johan Sorensen]
* Fixed that on very rare occasions, webrick would raise a NoMethodError: private method 'split' called for nil #1001 [Flurin Egger]
@@ -104,7 +104,7 @@ def select_second(datetime, options = {})
second_options = []
0.upto(59) do |second|
- second_options << ((datetime.kind_of?(Fixnum) ? datetime : datetime.sec) == second ?
+ second_options << ((datetime && (datetime.kind_of?(Fixnum) ? datetime : datetime.sec) == second) ?
"<option selected=\"selected\">#{leading_zero_on_single_digits(second)}</option>\n" :
"<option>#{leading_zero_on_single_digits(second)}</option>\n"
)
@@ -119,7 +119,7 @@ def select_minute(datetime, options = {})
minute_options = []
0.upto(59) do |minute|
- minute_options << ((datetime.kind_of?(Fixnum) ? datetime : datetime.min) == minute ?
+ minute_options << ((datetime && (datetime.kind_of?(Fixnum) ? datetime : datetime.min) == minute) ?
"<option selected=\"selected\">#{leading_zero_on_single_digits(minute)}</option>\n" :
"<option>#{leading_zero_on_single_digits(minute)}</option>\n"
)
@@ -134,7 +134,7 @@ def select_hour(datetime, options = {})
hour_options = []
0.upto(23) do |hour|
- hour_options << ((datetime.kind_of?(Fixnum) ? datetime : datetime.hour) == hour ?
+ hour_options << ((datetime && (datetime.kind_of?(Fixnum) ? datetime : datetime.hour) == hour) ?
"<option selected=\"selected\">#{leading_zero_on_single_digits(hour)}</option>\n" :
"<option>#{leading_zero_on_single_digits(hour)}</option>\n"
)
@@ -149,7 +149,7 @@ def select_day(date, options = {})
day_options = []
1.upto(31) do |day|
- day_options << ((date.kind_of?(Fixnum) ? date : date.day) == day ?
+ day_options << ((date && (date.kind_of?(Fixnum) ? date : date.day) == day) ?
"<option selected=\"selected\">#{day}</option>\n" :
"<option>#{day}</option>\n"
)
@@ -179,7 +179,7 @@ def select_month(date, options = {})
Date::MONTHNAMES[month_number]
end
- month_options << ((date.kind_of?(Fixnum) ? date : date.month) == month_number ?
+ month_options << ((date && (date.kind_of?(Fixnum) ? date : date.month) == month_number) ?
%(<option value="#{month_number}" selected="selected">#{month_name}</option>\n) :
%(<option value="#{month_number}">#{month_name}</option>\n)
)
@@ -195,11 +195,11 @@ def select_month(date, options = {})
# select_year(Date.today, :start_year => 1992, :end_year => 2007)
def select_year(date, options = {})
year_options = []
- y = date.kind_of?(Fixnum) ? (y = (date == 0) ? Date.today.year : date) : date.year
+ y = date ? (date.kind_of?(Fixnum) ? (y = (date == 0) ? Date.today.year : date) : date.year) : Date.today.year
default_start_year, default_end_year = y-5, y+5
(options[:start_year] || default_start_year).upto(options[:end_year] || default_end_year) do |year|
- year_options << ((date.kind_of?(Fixnum) ? date : date.year) == year ?
+ year_options << ((date && (date.kind_of?(Fixnum) ? date : date.year) == year) ?
"<option selected=\"selected\">#{year}</option>\n" :
"<option>#{year}</option>\n"
)
@@ -256,7 +256,7 @@ def to_datetime_select_tag(options = {})
defaults = { :discard_type => true }
options = defaults.merge(options)
options_with_prefix = Proc.new { |position| options.merge(:prefix => "#{@object_name}[#{@method_name}(#{position}i)]") }
- datetime = options[:include_blank] ? (value || 0) : (value || Time.now)
+ datetime = options[:include_blank] ? (value || nil) : (value || Time.now)
datetime_select = select_year(datetime, options_with_prefix.call(1))
datetime_select << select_month(datetime, options_with_prefix.call(2)) unless options[:discard_month]
@@ -268,4 +268,4 @@ def to_datetime_select_tag(options = {})
end
end
end
-end
+end
Oops, something went wrong.

0 comments on commit 7d09b8d

Please sign in to comment.