diff options
author | Jamis Buck <jamis@37signals.com> | 2005-08-22 14:47:16 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-08-22 14:47:16 +0000 |
commit | 82f44f314402cbd4627caa1c8ba24c35a5c875dd (patch) | |
tree | cd553b5c20ee9e2340a0fb5a5e0ee54e9d72db30 /actionpack/lib/action_view | |
parent | c031a0163356502392f1e6b2839eb248909f9def (diff) | |
download | rails-82f44f314402cbd4627caa1c8ba24c35a5c875dd.tar.gz rails-82f44f314402cbd4627caa1c8ba24c35a5c875dd.tar.bz2 rails-82f44f314402cbd4627caa1c8ba24c35a5c875dd.zip |
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
Diffstat (limited to 'actionpack/lib/action_view')
-rwxr-xr-x | actionpack/lib/action_view/helpers/date_helper.rb | 8 |
1 files changed, 6 insertions, 2 deletions
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 <tt>:field_name</tt> option, 'month' by default. + # + # If you would prefer to show month names as abbreviations, set the + # <tt>:use_short_month</tt> 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) ? |