def select_year(date, options = {}, html_options = {})
val = date ? (date.kind_of?(Fixnum) ? date : date.year) : ''
if options[:use_hidden]
hidden_html(options[:field_name] || 'year', val, options)
else
year_options = []
y = date ? (date.kind_of?(Fixnum) ? (y = (date == 0) ? Date.today.year : date) : date.year) : Date.today.year
start_year, end_year = (options[:start_year] || y-5), (options[:end_year] || y+5)
step_val = start_year < end_year ? 1 : -1
start_year.step(end_year, step_val) do |year|
year_options << ((val == year) ?
content_tag(:option, year, :value => year, :selected => "selected") :
content_tag(:option, year, :value => year)
)
year_options << "\n"
end
select_html(options[:field_name] || 'year', year_options.join, options, html_options)
end
end