From 82f645383e5a69631a8f75b47b68262c6d9905dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lennart=20Fride=CC=81n?= Date: Sun, 22 Jan 2012 16:28:44 +0100 Subject: Documented the :use_two_digit_numbers option --- actionpack/lib/action_view/helpers/date_helper.rb | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index f5077b034a..c8301965d9 100644 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -142,6 +142,8 @@ module ActionView # ==== Options # * :use_month_numbers - Set to true if you want to use month numbers rather than month names (e.g. # "2" instead of "February"). + # * :use_two_digit_numbers - Set to true if you want to display two digit month and day numbers (e.g. + # "02" instead of "February" and "08" instead of "8"). # * :use_short_month - Set to true if you want to use abbreviated month names instead of full # month names (e.g. "Feb" instead of "February"). # * :add_month_numbers - Set to true if you want to use both month numbers and month names (e.g. @@ -189,6 +191,10 @@ module ActionView # date_select("article", "written_on", :start_year => 1995, :use_month_numbers => true, # :discard_day => true, :include_blank => true) # + # # Generates a date select that when POSTed is stored in the article variable, in the written_on attribute, + # # with two digit numbers used for months and days. + # date_select("article", "written_on", :use_two_digit_numbers => true) + # # # Generates a date select that when POSTed is stored in the article variable, in the written_on attribute # # with the fields ordered as day, month, year rather than month, day, year. # date_select("article", "written_on", :order => [:day, :month, :year]) @@ -502,6 +508,7 @@ module ActionView # Returns a select tag with options for each of the days 1 through 31 with the current day selected. # The date can also be substituted for a day number. + # If you want to display days with a leading zero set the :use_two_digit_numbers key in +options+ to true. # Override the field name using the :field_name option, 'day' by default. # # ==== Examples @@ -513,6 +520,9 @@ module ActionView # # Generates a select field for days that defaults to the number given. # select_day(5) # + # # Generates a select field for days that defaults to the number given, but displays it with two digits. + # select_day(5, :use_two_digit_numbers => true) + # # # Generates a select field for days that defaults to the day for the date in my_date # # that is named 'due' rather than 'day'. # select_day(my_time, :field_name => 'due') @@ -532,6 +542,7 @@ module ActionView # want both numbers and names, set the :add_month_numbers key in +options+ to true. If you would prefer # to show month names as abbreviations, set the :use_short_month key in +options+ to true. If you want # to use your own month names, set the :use_month_names key in +options+ to an array of 12 month names. + # If you want to display months with a leading zero set the :use_two_digit_numbers key in +options+ to true. # Override the field name using the :field_name option, 'month' by default. # # ==== Examples @@ -559,6 +570,10 @@ module ActionView # # will use keys like "Januar", "Marts." # select_month(Date.today, :use_month_names => %w(Januar Februar Marts ...)) # + # # Generates a select field for months that defaults to the current month that + # # will use keys with two digit numbers like "01", "03". + # select_month(Date.today, :use_two_digit_numbers => true) + # # # Generates a select field for months with a custom prompt. Use :prompt => true for a # # generic prompt. # select_month(14, :prompt => 'Choose month') @@ -817,6 +832,9 @@ module ActionView # If :use_month_numbers option is passed # month_name(1) => 1 # + # If :use_two_month_numbers option is passed + # month_name(1) => '01' + # # If :add_month_numbers option is passed # month_name(1) => "1 - January" def month_name(number) @@ -850,6 +868,12 @@ module ActionView # # ..." # + # If :use_two_digit_numbers => true option is passed + # build_options(15, :start => 1, :end => 31, :use_two_digit_numbers => true) + # => " + # + # ..." + # # If :step options is passed # build_options(15, :start => 1, :end => 31, :step => 2) # => " -- cgit v1.2.3