class ActionView::Helpers::DateTimeSelector
def build_year_options(selected, options = {})
=> "
build_year_options(1998, start: 1998, end: 2000, year_format: ->year { "Heisei #{ year - 1988 }" })
If year_format option is passed
"
=> "
build_year_options(1998, start: 1998, end: 2000)
If year_format option is not passed
Build select option HTML for year.
def build_year_options(selected, options = {}) start = options.delete(:start) stop = options.delete(:end) step = options.delete(:step) select_options = [] start.step(stop, step) do |value| tag_options = { value: value } tag_options[:selected] = "selected" if selected == value text = year_name(value) select_options << content_tag("option", text, tag_options) end (select_options.join("\n") + "\n").html_safe end