diff options
author | Aditya Sanghi <asanghi@me.com> | 2011-04-29 02:03:56 +0530 |
---|---|---|
committer | Aditya Sanghi <asanghi@me.com> | 2011-04-29 02:03:56 +0530 |
commit | 610e4d9f24b8fe0c372104481a733b48d2270c3f (patch) | |
tree | bafd5f05ceb0fc6e1ddcfc5e062fcb1ebb7fc505 /actionpack/lib/action_view | |
parent | a869382a9fa241f72a7a73d4a9738531c4c37ba5 (diff) | |
download | rails-610e4d9f24b8fe0c372104481a733b48d2270c3f.tar.gz rails-610e4d9f24b8fe0c372104481a733b48d2270c3f.tar.bz2 rails-610e4d9f24b8fe0c372104481a733b48d2270c3f.zip |
add more documentation; remove unused assignment
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/date_helper.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index 7e8ad54d5f..9e1be05e6c 100644 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -207,7 +207,8 @@ module ActionView # Returns a set of select tags (one for hour, minute and optionally second) pre-selected for accessing a # specified time-based attribute (identified by +method+) on an object assigned to the template (identified by - # +object+). You can include the seconds with <tt>:include_seconds</tt>. + # +object+). You can include the seconds with <tt>:include_seconds</tt>. You can get hours in the AM/PM format + # with <tt>:ampm</tt> option. # # This method will also generate 3 input hidden tags, for the actual year, month and day unless the option # <tt>:ignore_date</tt> is set to +true+. @@ -230,6 +231,9 @@ module ActionView # time_select("post", "written_on", :prompt => {:hour => true}) # generic prompt for hours # time_select("post", "written_on", :prompt => true) # generic prompts for all # + # # You can set :ampm option to true which will show the hours as: 12 PM, 01 AM .. 11 PM. + # time_select 'game', 'game_time', {:ampm => true} + # # The selects are prepared for multi-parameter assignment to an Active Record object. # # Note: If the day is not included as an option but the month is, the day will be set to the 1st to ensure that @@ -257,6 +261,9 @@ module ActionView # # be stored in the trip variable in the departing attribute. # datetime_select("trip", "departing", :default => 3.days.from_now) # + # # Generate a datetime select with hours in the AM/PM format + # datetime_select("post", "written_on", :ampm => true) + # # # Generates a datetime select that discards the type that, when POSTed, will be stored in the post variable # # as the written_on attribute. # datetime_select("post", "written_on", :discard_type => true) @@ -306,6 +313,9 @@ module ActionView # # my_date_time (four days after today) # select_datetime(my_date_time, :discard_type => true) # + # # Generate a datetime field with hours in the AM/PM format + # select_datetime(my_date_time, :ampm => true) + # # # Generates a datetime select that defaults to the datetime in my_date_time (four days after today) # # prefixed with 'payday' rather than 'date' # select_datetime(my_date_time, :prefix => 'payday') @@ -387,6 +397,9 @@ module ActionView # # separated by ':' and includes an input for seconds # select_time(my_time, :time_separator => ':', :include_seconds => true) # + # # Generate a time select field with hours in the AM/PM format + # select_time(my_time, :ampm => true) + # # # Generates a time select with a custom prompt. Use :prompt=>true for generic prompts. # select_time(my_time, :prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year'}) # select_time(my_time, :prompt => {:hour => true}) # generic prompt for hours @@ -603,9 +616,6 @@ module ActionView POSITION = { :year => 1, :month => 2, :day => 3, :hour => 4, :minute => 5, :second => 6 }.freeze - ampm = ["AM","PM"].map do |s| - ["12 #{s}"] + (1..11).map{|x| "#{sprintf('%02d',x)} #{s}"} - end.flatten AMPM_TRANSLATION = Hash[ [[0, "12 AM"], [1, "01 AM"], [2, "02 AM"], [3, "03 AM"], |