From 82f44f314402cbd4627caa1c8ba24c35a5c875dd Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Mon, 22 Aug 2005 14:47:16 +0000 Subject: Added :use_short_month option to select_month helper to show month names as abbreviations git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2033 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/helpers/date_helper.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index 4b75e08e69..a516072acb 100755 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -181,16 +181,20 @@ module ActionView # select_month(Date.today, :add_month_numbers => true) # Will use keys like "1 - January", "3 - March" # # Override the field name using the :field_name option, 'month' by default. + # + # If you would prefer to show month names as abbreviations, set the + # :use_short_month key in +options+ to true. def select_month(date, options = {}) month_options = [] + month_names = options[:use_short_month] ? Date::ABBR_MONTHNAMES : Date::MONTHNAMES 1.upto(12) do |month_number| month_name = if options[:use_month_numbers] month_number elsif options[:add_month_numbers] - month_number.to_s + ' - ' + Date::MONTHNAMES[month_number] + month_number.to_s + ' - ' + month_names[month_number] else - Date::MONTHNAMES[month_number] + month_names[month_number] end month_options << ((date && (date.kind_of?(Fixnum) ? date : date.month) == month_number) ? -- cgit v1.2.3