Skip to content

Commit

Permalink
add more documentation; remove unused assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya Sanghi committed Apr 28, 2011
1 parent a869382 commit 610e4d9
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions actionpack/lib/action_view/helpers/date_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ def date_select(object_name, method, options = {}, html_options = {})

# 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+.
Expand All @@ -230,6 +231,9 @@ def date_select(object_name, method, options = {}, html_options = {})
# 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
Expand Down Expand Up @@ -257,6 +261,9 @@ def time_select(object_name, method, options = {}, html_options = {})
# # 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)
Expand Down Expand Up @@ -306,6 +313,9 @@ def datetime_select(object_name, method, options = {}, html_options = {})
# # 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')
Expand Down Expand Up @@ -387,6 +397,9 @@ def select_date(date = Date.current, options = {}, html_options = {})
# # 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
Expand Down Expand Up @@ -603,9 +616,6 @@ class DateTimeSelector #:nodoc:
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"],
Expand Down

0 comments on commit 610e4d9

Please sign in to comment.