Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 8b99df826c3b6cf56a1caaae5f931d50 > files > 756

ruby-actionpack-2.3.4-1mdv2010.0.noarch.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActionView::Helpers::DateHelper</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActionView::Helpers::DateHelper</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/lib/action_view/helpers/date_helper_rb.html">
                lib/action_view/helpers/date_helper.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
The Date Helper primarily creates select/option tags for different kinds of
dates and date elements. All of the select-type methods share a number of
common options that are as follows:
</p>
<ul>
<li><tt>:prefix</tt> - overwrites the default prefix of &quot;date&quot; used
for the select names. So specifying &quot;birthday&quot;

</li>
</ul>
<p>
would give birthday[month] instead of date[month] if passed to the <a
href="DateHelper.html#M000530">select_month</a> method.
</p>
<ul>
<li><tt>:include_blank</tt> - set to true if it should be possible to set an
empty date.

</li>
<li><tt>:discard_type</tt> - set to true if you want to discard the type part
of the select name. If set to true, the <a
href="DateHelper.html#M000530">select_month</a> method would use simply
&quot;date&quot; (which can be overwritten using <tt>:prefix</tt>) instead
of &quot;date[month]&quot;.

</li>
</ul>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000520">date_select</a>&nbsp;&nbsp;
      <a href="#M000522">datetime_select</a>&nbsp;&nbsp;
      <a href="#M000517">distance_of_time_in_words</a>&nbsp;&nbsp;
      <a href="#M000519">distance_of_time_in_words_to_now</a>&nbsp;&nbsp;
      <a href="#M000524">select_date</a>&nbsp;&nbsp;
      <a href="#M000523">select_datetime</a>&nbsp;&nbsp;
      <a href="#M000529">select_day</a>&nbsp;&nbsp;
      <a href="#M000528">select_hour</a>&nbsp;&nbsp;
      <a href="#M000527">select_minute</a>&nbsp;&nbsp;
      <a href="#M000530">select_month</a>&nbsp;&nbsp;
      <a href="#M000526">select_second</a>&nbsp;&nbsp;
      <a href="#M000525">select_time</a>&nbsp;&nbsp;
      <a href="#M000531">select_year</a>&nbsp;&nbsp;
      <a href="#M000518">time_ago_in_words</a>&nbsp;&nbsp;
      <a href="#M000521">time_select</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000520" class="method-detail">
        <a name="M000520"></a>

        <div class="method-heading">
          <a href="DateHelper.src/M000520.html" target="Code" class="method-signature"
            onclick="popupCode('DateHelper.src/M000520.html');return false;">
          <span class="method-name">date_select</span><span class="method-args">(object_name, method, options = {}, html_options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a set of select tags (one for year, month, and day) pre-selected
for accessing a specified date-based attribute (identified by
<tt>method</tt>) on an object assigned to the template (identified by
<tt>object</tt>). You can the output in the <tt>options</tt> hash.
</p>
<h4>Options</h4>
<ul>
<li><tt>:use_month_numbers</tt> - Set to true if you want to use month numbers
rather than month names (e.g. &quot;2&quot; instead of
&quot;February&quot;).

</li>
<li><tt>:use_short_month</tt> - Set to true if you want to use the abbreviated
month name instead of the full name (e.g. &quot;Feb&quot; instead of
&quot;February&quot;).

</li>
<li><tt>:add_month_number</tt> - Set to true if you want to show both, the
month&#8216;s number and name (e.g. &quot;2 - February&quot; instead of
&quot;February&quot;).

</li>
<li><tt>:use_month_names</tt> - Set to an array with 12 month names if you want
to customize month names. Note: You can also use Rails&#8217; new i18n
functionality for this.

</li>
<li><tt>:date_separator</tt> - Specifies a string to separate the date fields.
Default is &quot;&quot; (i.e. nothing).

</li>
<li><tt>:start_year</tt> - Set the start year for the year select. Default is
<tt>Time.now.year - 5</tt>.

</li>
<li><tt>:end_year</tt> - Set the end year for the year select. Default is
<tt>Time.now.year + 5</tt>.

</li>
<li><tt>:discard_day</tt> - Set to true if you don&#8216;t want to show a day
select. This includes the day as a hidden field instead of showing a select
field. Also note that this implicitly sets the day to be the first of the
given month in order to not create invalid dates like 31 February.

</li>
<li><tt>:discard_month</tt> - Set to true if you don&#8216;t want to show a
month select. This includes the month as a hidden field instead of showing
a select field. Also note that this implicitly sets :discard_day to true.

</li>
<li><tt>:discard_year</tt> - Set to true if you don&#8216;t want to show a year
select. This includes the year as a hidden field instead of showing a
select field.

</li>
<li><tt>:order</tt> - Set to an array containing <tt>:day</tt>, <tt>:month</tt>
and <tt>:year</tt> do customize the order in which the select fields are
shown. If you leave out any of the symbols, the respective select will not
be shown (like when you set <tt>:discard_xxx =&gt; true</tt>. Defaults to
the order defined in the respective locale (e.g. [:year, :month, :day] in
the en locale that ships with Rails).

</li>
<li><tt>:include_blank</tt> - Include a blank option in every select field so
it&#8216;s possible to set empty dates.

</li>
<li><tt>:default</tt> - Set a default date if the affected date isn&#8216;t set
or is nil.

</li>
<li><tt>:disabled</tt> - Set to true if you want show the select fields as
disabled.

</li>
<li><tt>:prompt</tt> - Set to true (for a generic prompt), a prompt string or a
hash of prompt strings for <tt>:year</tt>, <tt>:month</tt>, <tt>:day</tt>,
<tt>:hour</tt>, <tt>:minute</tt> and <tt>:second</tt>. Setting this option
prepends a select option with a generic prompt (Day, Month, Year, Hour,
Minute, Seconds) or the given prompt string.

</li>
</ul>
<p>
If anything is passed in the <tt>html_options</tt> hash it will be applied
to every select tag in the set.
</p>
<p>
NOTE: Discarded selects will default to 1. So if no month select is
available, January will be assumed.
</p>
<h4>Examples</h4>
<pre>
  # Generates a date select that when POSTed is stored in the post variable, in the written_on attribute
  date_select(&quot;post&quot;, &quot;written_on&quot;)

  # Generates a date select that when POSTed is stored in the post variable, in the written_on attribute,
  # with the year in the year drop down box starting at 1995.
  date_select(&quot;post&quot;, &quot;written_on&quot;, :start_year =&gt; 1995)

  # Generates a date select that when POSTed is stored in the post variable, in the written_on attribute,
  # with the year in the year drop down box starting at 1995, numbers used for months instead of words,
  # and without a day select box.
  date_select(&quot;post&quot;, &quot;written_on&quot;, :start_year =&gt; 1995, :use_month_numbers =&gt; true,
                                    :discard_day =&gt; true, :include_blank =&gt; true)

  # Generates a date select that when POSTed is stored in the post variable, in the written_on attribute
  # with the fields ordered as day, month, year rather than month, day, year.
  date_select(&quot;post&quot;, &quot;written_on&quot;, :order =&gt; [:day, :month, :year])

  # Generates a date select that when POSTed is stored in the user variable, in the birthday attribute
  # lacking a year field.
  date_select(&quot;user&quot;, &quot;birthday&quot;, :order =&gt; [:month, :day])

  # Generates a date select that when POSTed is stored in the user variable, in the birthday attribute
  # which is initially set to the date 3 days from the current date
  date_select(&quot;post&quot;, &quot;written_on&quot;, :default =&gt; 3.days.from_now)

  # Generates a date select that when POSTed is stored in the credit_card variable, in the bill_due attribute
  # that will have a default day of 20.
  date_select(&quot;credit_card&quot;, &quot;bill_due&quot;, :default =&gt; { :day =&gt; 20 })

  # Generates a date select with custom prompts
  date_select(&quot;post&quot;, &quot;written_on&quot;, :prompt =&gt; { :day =&gt; 'Select day', :month =&gt; 'Select month', :year =&gt; 'Select year' })
</pre>
<p>
The selects are prepared for multi-parameter assignment to an Active Record
object.
</p>
<p>
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 all month choices are valid.
</p>
        </div>
      </div>

      <div id="method-M000522" class="method-detail">
        <a name="M000522"></a>

        <div class="method-heading">
          <a href="DateHelper.src/M000522.html" target="Code" class="method-signature"
            onclick="popupCode('DateHelper.src/M000522.html');return false;">
          <span class="method-name">datetime_select</span><span class="method-args">(object_name, method, options = {}, html_options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a set of select tags (one for year, month, day, hour, and minute)
pre-selected for accessing a specified datetime-based attribute (identified
by <tt>method</tt>) on an object assigned to the template (identified by
<tt>object</tt>). Examples:
</p>
<p>
If anything is passed in the html_options hash it will be applied to every
select tag in the set.
</p>
<h4>Examples</h4>
<pre>
  # Generates a datetime select that, when POSTed, will be stored in the post variable in the written_on
  # attribute
  datetime_select(&quot;post&quot;, &quot;written_on&quot;)

  # Generates a datetime select with a year select that starts at 1995 that, when POSTed, will be stored in the
  # post variable in the written_on attribute.
  datetime_select(&quot;post&quot;, &quot;written_on&quot;, :start_year =&gt; 1995)

  # Generates a datetime select with a default value of 3 days from the current time that, when POSTed, will
  # be stored in the trip variable in the departing attribute.
  datetime_select(&quot;trip&quot;, &quot;departing&quot;, :default =&gt; 3.days.from_now)

  # 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(&quot;post&quot;, &quot;written_on&quot;, :discard_type =&gt; true)

  # Generates a datetime select with a custom prompt. Use :prompt=&gt;true for generic prompts.
  datetime_select(&quot;post&quot;, &quot;written_on&quot;, :prompt =&gt; {:day =&gt; 'Choose day', :month =&gt; 'Choose month', :year =&gt; 'Choose year'})
  datetime_select(&quot;post&quot;, &quot;written_on&quot;, :prompt =&gt; {:hour =&gt; true}) # generic prompt for hours
  datetime_select(&quot;post&quot;, &quot;written_on&quot;, :prompt =&gt; true) # generic prompts for all
</pre>
<p>
The selects are prepared for multi-parameter assignment to an Active Record
object.
</p>
        </div>
      </div>

      <div id="method-M000517" class="method-detail">
        <a name="M000517"></a>

        <div class="method-heading">
          <a href="DateHelper.src/M000517.html" target="Code" class="method-signature"
            onclick="popupCode('DateHelper.src/M000517.html');return false;">
          <span class="method-name">distance_of_time_in_words</span><span class="method-args">(from_time, to_time = 0, include_seconds = false, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Reports the approximate distance in time between two Time or Date objects
or integers as seconds. Set <tt>include_seconds</tt> to true if you want
more detailed approximations when distance &lt; 1 min, 29 secs Distances
are reported based on the following table:
</p>
<pre>
  0 &lt;-&gt; 29 secs                                                             # =&gt; less than a minute
  30 secs &lt;-&gt; 1 min, 29 secs                                                # =&gt; 1 minute
  1 min, 30 secs &lt;-&gt; 44 mins, 29 secs                                       # =&gt; [2..44] minutes
  44 mins, 30 secs &lt;-&gt; 89 mins, 29 secs                                     # =&gt; about 1 hour
  89 mins, 29 secs &lt;-&gt; 23 hrs, 59 mins, 29 secs                             # =&gt; about [2..24] hours
  23 hrs, 59 mins, 29 secs &lt;-&gt; 47 hrs, 59 mins, 29 secs                     # =&gt; 1 day
  47 hrs, 59 mins, 29 secs &lt;-&gt; 29 days, 23 hrs, 59 mins, 29 secs            # =&gt; [2..29] days
  29 days, 23 hrs, 59 mins, 30 secs &lt;-&gt; 59 days, 23 hrs, 59 mins, 29 secs   # =&gt; about 1 month
  59 days, 23 hrs, 59 mins, 30 secs &lt;-&gt; 1 yr minus 1 sec                    # =&gt; [2..12] months
  1 yr &lt;-&gt; 2 yrs minus 1 secs                                               # =&gt; about 1 year
  2 yrs &lt;-&gt; max time or date                                                # =&gt; over [2..X] years
</pre>
<p>
With <tt>include_seconds</tt> = true and the difference &lt; 1 minute 29
seconds:
</p>
<pre>
  0-4   secs      # =&gt; less than 5 seconds
  5-9   secs      # =&gt; less than 10 seconds
  10-19 secs      # =&gt; less than 20 seconds
  20-39 secs      # =&gt; half a minute
  40-59 secs      # =&gt; less than a minute
  60-89 secs      # =&gt; 1 minute
</pre>
<h4>Examples</h4>
<pre>
  from_time = Time.now
  distance_of_time_in_words(from_time, from_time + 50.minutes)        # =&gt; about 1 hour
  distance_of_time_in_words(from_time, 50.minutes.from_now)           # =&gt; about 1 hour
  distance_of_time_in_words(from_time, from_time + 15.seconds)        # =&gt; less than a minute
  distance_of_time_in_words(from_time, from_time + 15.seconds, true)  # =&gt; less than 20 seconds
  distance_of_time_in_words(from_time, 3.years.from_now)              # =&gt; over 3 years
  distance_of_time_in_words(from_time, from_time + 60.hours)          # =&gt; about 3 days
  distance_of_time_in_words(from_time, from_time + 45.seconds, true)  # =&gt; less than a minute
  distance_of_time_in_words(from_time, from_time - 45.seconds, true)  # =&gt; less than a minute
  distance_of_time_in_words(from_time, 76.seconds.from_now)           # =&gt; 1 minute
  distance_of_time_in_words(from_time, from_time + 1.year + 3.days)   # =&gt; about 1 year
  distance_of_time_in_words(from_time, from_time + 4.years + 9.days + 30.minutes + 5.seconds) # =&gt; over 4 years

  to_time = Time.now + 6.years + 19.days
  distance_of_time_in_words(from_time, to_time, true)     # =&gt; over 6 years
  distance_of_time_in_words(to_time, from_time, true)     # =&gt; over 6 years
  distance_of_time_in_words(Time.now, Time.now)           # =&gt; less than a minute
</pre>
        </div>
      </div>

      <div id="method-M000519" class="method-detail">
        <a name="M000519"></a>

        <div class="method-heading">
          <span class="method-name">distance_of_time_in_words_to_now</span><span class="method-args">(from_time, include_seconds = false)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="DateHelper.html#M000518">time_ago_in_words</a>
</p>
        </div>
      </div>

      <div id="method-M000524" class="method-detail">
        <a name="M000524"></a>

        <div class="method-heading">
          <a href="DateHelper.src/M000524.html" target="Code" class="method-signature"
            onclick="popupCode('DateHelper.src/M000524.html');return false;">
          <span class="method-name">select_date</span><span class="method-args">(date = Date.current, options = {}, html_options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a set of html select-tags (one for year, month, and day)
pre-selected with the <tt>date</tt>. It&#8216;s possible to explicitly set
the order of the tags using the <tt>:order</tt> option with an array of
symbols <tt>:year</tt>, <tt>:month</tt> and <tt>:day</tt> in the desired
order. If you do not supply a Symbol, it will be appended onto the
<tt>:order</tt> passed in.
</p>
<p>
If anything is passed in the html_options hash it will be applied to every
select tag in the set.
</p>
<h4>Examples</h4>
<pre>
  my_date = Time.today + 6.days

  # Generates a date select that defaults to the date in my_date (six days after today)
  select_date(my_date)

  # Generates a date select that defaults to today (no specified date)
  select_date()

  # Generates a date select that defaults to the date in my_date (six days after today)
  # with the fields ordered year, month, day rather than month, day, year.
  select_date(my_date, :order =&gt; [:year, :month, :day])

  # Generates a date select that discards the type of the field and defaults to the date in
  # my_date (six days after today)
  select_date(my_date, :discard_type =&gt; true)

  # Generates a date select that defaults to the date in my_date,
  # which has fields separated by '/'
  select_date(my_date, :date_separator =&gt; '/')

  # Generates a date select that defaults to the datetime in my_date (six days after today)
  # prefixed with 'payday' rather than 'date'
  select_date(my_date, :prefix =&gt; 'payday')

  # Generates a date select with a custom prompt. Use :prompt=&gt;true for generic prompts.
  select_date(my_date, :prompt =&gt; {:day =&gt; 'Choose day', :month =&gt; 'Choose month', :year =&gt; 'Choose year'})
  select_date(my_date, :prompt =&gt; {:hour =&gt; true}) # generic prompt for hours
  select_date(my_date, :prompt =&gt; true) # generic prompts for all
</pre>
        </div>
      </div>

      <div id="method-M000523" class="method-detail">
        <a name="M000523"></a>

        <div class="method-heading">
          <a href="DateHelper.src/M000523.html" target="Code" class="method-signature"
            onclick="popupCode('DateHelper.src/M000523.html');return false;">
          <span class="method-name">select_datetime</span><span class="method-args">(datetime = Time.current, options = {}, html_options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a set of html select-tags (one for year, month, day, hour, and
minute) pre-selected with the <tt>datetime</tt>. It&#8216;s also possible
to explicitly set the order of the tags using the <tt>:order</tt> option
with an array of symbols <tt>:year</tt>, <tt>:month</tt> and <tt>:day</tt>
in the desired order. If you do not supply a Symbol, it will be appended
onto the <tt>:order</tt> passed in. You can also add
<tt>:date_separator</tt>, <tt>:datetime_separator</tt> and
<tt>:time_separator</tt> keys to the <tt>options</tt> to control visual
display of the elements.
</p>
<p>
If anything is passed in the html_options hash it will be applied to every
select tag in the set.
</p>
<h4>Examples</h4>
<pre>
  my_date_time = Time.now + 4.days

  # Generates a datetime select that defaults to the datetime in my_date_time (four days after today)
  select_datetime(my_date_time)

  # Generates a datetime select that defaults to today (no specified datetime)
  select_datetime()

  # Generates a datetime select that defaults to the datetime in my_date_time (four days after today)
  # with the fields ordered year, month, day rather than month, day, year.
  select_datetime(my_date_time, :order =&gt; [:year, :month, :day])

  # Generates a datetime select that defaults to the datetime in my_date_time (four days after today)
  # with a '/' between each date field.
  select_datetime(my_date_time, :date_separator =&gt; '/')

  # Generates a datetime select that defaults to the datetime in my_date_time (four days after today)
  # with a date fields separated by '/', time fields separated by '' and the date and time fields
  # separated by a comma (',').
  select_datetime(my_date_time, :date_separator =&gt; '/', :time_separator =&gt; '', :datetime_separator =&gt; ',')

  # Generates a datetime select that discards the type of the field and defaults to the datetime in
  # my_date_time (four days after today)
  select_datetime(my_date_time, :discard_type =&gt; 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 =&gt; 'payday')

  # Generates a datetime select with a custom prompt. Use :prompt=&gt;true for generic prompts.
  select_datetime(my_date_time, :prompt =&gt; {:day =&gt; 'Choose day', :month =&gt; 'Choose month', :year =&gt; 'Choose year'})
  select_datetime(my_date_time, :prompt =&gt; {:hour =&gt; true}) # generic prompt for hours
  select_datetime(my_date_time, :prompt =&gt; true) # generic prompts for all
</pre>
        </div>
      </div>

      <div id="method-M000529" class="method-detail">
        <a name="M000529"></a>

        <div class="method-heading">
          <a href="DateHelper.src/M000529.html" target="Code" class="method-signature"
            onclick="popupCode('DateHelper.src/M000529.html');return false;">
          <span class="method-name">select_day</span><span class="method-args">(date, options = {}, html_options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a select tag with options for each of the days 1 through 31 with
the current day selected. The <tt>date</tt> can also be substituted for a
hour number. Override the field name using the <tt>:field_name</tt> option,
&#8216;day&#8217; by default.
</p>
<h4>Examples</h4>
<pre>
  my_date = Time.today + 2.days

  # Generates a select field for days that defaults to the day for the date in my_date
  select_day(my_time)

  # 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 day for the date in my_date
  # that is named 'due' rather than 'day'
  select_day(my_time, :field_name =&gt; 'due')

  # Generates a select field for days with a custom prompt.  Use :prompt =&gt; true for a
  # generic prompt.
  select_day(5, :prompt =&gt; 'Choose day')
</pre>
        </div>
      </div>

      <div id="method-M000528" class="method-detail">
        <a name="M000528"></a>

        <div class="method-heading">
          <a href="DateHelper.src/M000528.html" target="Code" class="method-signature"
            onclick="popupCode('DateHelper.src/M000528.html');return false;">
          <span class="method-name">select_hour</span><span class="method-args">(datetime, options = {}, html_options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a select tag with options for each of the hours 0 through 23 with
the current hour selected. The <tt>hour</tt> can also be substituted for a
hour number. Override the field name using the <tt>:field_name</tt> option,
&#8216;hour&#8217; by default.
</p>
<h4>Examples</h4>
<pre>
  my_time = Time.now + 6.hours

  # Generates a select field for hours that defaults to the hour for the time in my_time
  select_hour(my_time)

  # Generates a select field for hours that defaults to the number given
  select_hour(13)

  # Generates a select field for hours that defaults to the minutes for the time in my_time
  # that is named 'stride' rather than 'second'
  select_hour(my_time, :field_name =&gt; 'stride')

  # Generates a select field for hours with a custom prompt.  Use :prompt =&gt; true for a
  # generic prompt.
  select_hour(13, :prompt =&gt;'Choose hour')
</pre>
        </div>
      </div>

      <div id="method-M000527" class="method-detail">
        <a name="M000527"></a>

        <div class="method-heading">
          <a href="DateHelper.src/M000527.html" target="Code" class="method-signature"
            onclick="popupCode('DateHelper.src/M000527.html');return false;">
          <span class="method-name">select_minute</span><span class="method-args">(datetime, options = {}, html_options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a select tag with options for each of the minutes 0 through 59 with
the current minute selected. Also can return a select tag with options by
<tt>minute_step</tt> from 0 through 59 with the 00 minute selected. The
<tt>minute</tt> can also be substituted for a minute number. Override the
field name using the <tt>:field_name</tt> option, &#8216;minute&#8217; by
default.
</p>
<h4>Examples</h4>
<pre>
  my_time = Time.now + 6.hours

  # Generates a select field for minutes that defaults to the minutes for the time in my_time
  select_minute(my_time)

  # Generates a select field for minutes that defaults to the number given
  select_minute(14)

  # Generates a select field for minutes that defaults to the minutes for the time in my_time
  # that is named 'stride' rather than 'second'
  select_minute(my_time, :field_name =&gt; 'stride')

  # Generates a select field for minutes with a custom prompt.  Use :prompt=&gt;true for a
  # generic prompt.
  select_minute(14, :prompt =&gt; 'Choose minutes')
</pre>
        </div>
      </div>

      <div id="method-M000530" class="method-detail">
        <a name="M000530"></a>

        <div class="method-heading">
          <a href="DateHelper.src/M000530.html" target="Code" class="method-signature"
            onclick="popupCode('DateHelper.src/M000530.html');return false;">
          <span class="method-name">select_month</span><span class="method-args">(date, options = {}, html_options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a select tag with options for each of the months January through
December with the current month selected. The month names are presented as
keys (what&#8216;s shown to the user) and the month numbers (1-12) are used
as values (what&#8216;s submitted to the server). It&#8216;s also possible
to use month numbers for the presentation instead of names &#8212; set the
<tt>:use_month_numbers</tt> key in <tt>options</tt> to true for this to
happen. If you want both numbers and names, set the
<tt>:add_month_numbers</tt> key in <tt>options</tt> to true. If you would
prefer to show month names as abbreviations, set the
<tt>:use_short_month</tt> key in <tt>options</tt> to true. If you want to
use your own month names, set the <tt>:use_month_names</tt> key in
<tt>options</tt> to an array of 12 month names. Override the field name
using the <tt>:field_name</tt> option, &#8216;month&#8217; by default.
</p>
<h4>Examples</h4>
<pre>
  # Generates a select field for months that defaults to the current month that
  # will use keys like &quot;January&quot;, &quot;March&quot;.
  select_month(Date.today)

  # Generates a select field for months that defaults to the current month that
  # is named &quot;start&quot; rather than &quot;month&quot;
  select_month(Date.today, :field_name =&gt; 'start')

  # Generates a select field for months that defaults to the current month that
  # will use keys like &quot;1&quot;, &quot;3&quot;.
  select_month(Date.today, :use_month_numbers =&gt; true)

  # Generates a select field for months that defaults to the current month that
  # will use keys like &quot;1 - January&quot;, &quot;3 - March&quot;.
  select_month(Date.today, :add_month_numbers =&gt; true)

  # Generates a select field for months that defaults to the current month that
  # will use keys like &quot;Jan&quot;, &quot;Mar&quot;.
  select_month(Date.today, :use_short_month =&gt; true)

  # Generates a select field for months that defaults to the current month that
  # will use keys like &quot;Januar&quot;, &quot;Marts.&quot;
  select_month(Date.today, :use_month_names =&gt; %w(Januar Februar Marts ...))

  # Generates a select field for months with a custom prompt.  Use :prompt =&gt; true for a
  # generic prompt.
  select_month(14, :prompt =&gt; 'Choose month')
</pre>
        </div>
      </div>

      <div id="method-M000526" class="method-detail">
        <a name="M000526"></a>

        <div class="method-heading">
          <a href="DateHelper.src/M000526.html" target="Code" class="method-signature"
            onclick="popupCode('DateHelper.src/M000526.html');return false;">
          <span class="method-name">select_second</span><span class="method-args">(datetime, options = {}, html_options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a select tag with options for each of the seconds 0 through 59 with
the current second selected. The <tt>second</tt> can also be substituted
for a second number. Override the field name using the <tt>:field_name</tt>
option, &#8216;second&#8217; by default.
</p>
<h4>Examples</h4>
<pre>
  my_time = Time.now + 16.minutes

  # Generates a select field for seconds that defaults to the seconds for the time in my_time
  select_second(my_time)

  # Generates a select field for seconds that defaults to the number given
  select_second(33)

  # Generates a select field for seconds that defaults to the seconds for the time in my_time
  # that is named 'interval' rather than 'second'
  select_second(my_time, :field_name =&gt; 'interval')

  # Generates a select field for seconds with a custom prompt.  Use :prompt=&gt;true for a
  # generic prompt.
  select_minute(14, :prompt =&gt; 'Choose seconds')
</pre>
        </div>
      </div>

      <div id="method-M000525" class="method-detail">
        <a name="M000525"></a>

        <div class="method-heading">
          <a href="DateHelper.src/M000525.html" target="Code" class="method-signature"
            onclick="popupCode('DateHelper.src/M000525.html');return false;">
          <span class="method-name">select_time</span><span class="method-args">(datetime = Time.current, options = {}, html_options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a set of html select-tags (one for hour and minute) You can set
<tt>:time_separator</tt> key to format the output, and the
<tt>:include_seconds</tt> option to include an input for seconds.
</p>
<p>
If anything is passed in the html_options hash it will be applied to every
select tag in the set.
</p>
<h4>Examples</h4>
<pre>
  my_time = Time.now + 5.days + 7.hours + 3.minutes + 14.seconds

  # Generates a time select that defaults to the time in my_time
  select_time(my_time)

  # Generates a time select that defaults to the current time (no specified time)
  select_time()

  # Generates a time select that defaults to the time in my_time,
  # which has fields separated by ':'
  select_time(my_time, :time_separator =&gt; ':')

  # Generates a time select that defaults to the time in my_time,
  # that also includes an input for seconds
  select_time(my_time, :include_seconds =&gt; true)

  # Generates a time select that defaults to the time in my_time, that has fields
  # separated by ':' and includes an input for seconds
  select_time(my_time, :time_separator =&gt; ':', :include_seconds =&gt; true)

  # Generates a time select with a custom prompt. Use :prompt=&gt;true for generic prompts.
  select_time(my_time, :prompt =&gt; {:day =&gt; 'Choose day', :month =&gt; 'Choose month', :year =&gt; 'Choose year'})
  select_time(my_time, :prompt =&gt; {:hour =&gt; true}) # generic prompt for hours
  select_time(my_time, :prompt =&gt; true) # generic prompts for all
</pre>
        </div>
      </div>

      <div id="method-M000531" class="method-detail">
        <a name="M000531"></a>

        <div class="method-heading">
          <a href="DateHelper.src/M000531.html" target="Code" class="method-signature"
            onclick="popupCode('DateHelper.src/M000531.html');return false;">
          <span class="method-name">select_year</span><span class="method-args">(date, options = {}, html_options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a select tag with options for each of the five years on each side
of the current, which is selected. The five year radius can be changed
using the <tt>:start_year</tt> and <tt>:end_year</tt> keys in the
<tt>options</tt>. Both ascending and descending year lists are supported by
making <tt>:start_year</tt> less than or greater than <tt>:end_year</tt>.
The <tt>date</tt> can also be substituted for a year given as a number.
Override the field name using the <tt>:field_name</tt> option,
&#8216;year&#8217; by default.
</p>
<h4>Examples</h4>
<pre>
  # Generates a select field for years that defaults to the current year that
  # has ascending year values
  select_year(Date.today, :start_year =&gt; 1992, :end_year =&gt; 2007)

  # Generates a select field for years that defaults to the current year that
  # is named 'birth' rather than 'year'
  select_year(Date.today, :field_name =&gt; 'birth')

  # Generates a select field for years that defaults to the current year that
  # has descending year values
  select_year(Date.today, :start_year =&gt; 2005, :end_year =&gt; 1900)

  # Generates a select field for years that defaults to the year 2006 that
  # has ascending year values
  select_year(2006, :start_year =&gt; 2000, :end_year =&gt; 2010)

  # Generates a select field for years with a custom prompt.  Use :prompt =&gt; true for a
  # generic prompt.
  select_year(14, :prompt =&gt; 'Choose year')
</pre>
        </div>
      </div>

      <div id="method-M000518" class="method-detail">
        <a name="M000518"></a>

        <div class="method-heading">
          <a href="DateHelper.src/M000518.html" target="Code" class="method-signature"
            onclick="popupCode('DateHelper.src/M000518.html');return false;">
          <span class="method-name">time_ago_in_words</span><span class="method-args">(from_time, include_seconds = false)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Like <a href="DateHelper.html#M000517">distance_of_time_in_words</a>, but
where <tt>to_time</tt> is fixed to <tt>Time.now</tt>.
</p>
<h4>Examples</h4>
<pre>
  time_ago_in_words(3.minutes.from_now)       # =&gt; 3 minutes
  time_ago_in_words(Time.now - 15.hours)      # =&gt; 15 hours
  time_ago_in_words(Time.now)                 # =&gt; less than a minute

  from_time = Time.now - 3.days - 14.minutes - 25.seconds     # =&gt; 3 days
</pre>
        </div>
      </div>

      <div id="method-M000521" class="method-detail">
        <a name="M000521"></a>

        <div class="method-heading">
          <a href="DateHelper.src/M000521.html" target="Code" class="method-signature"
            onclick="popupCode('DateHelper.src/M000521.html');return false;">
          <span class="method-name">time_select</span><span class="method-args">(object_name, method, options = {}, html_options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a set of select tags (one for hour, minute and optionally second)
pre-selected for accessing a specified time-based attribute (identified by
<tt>method</tt>) on an object assigned to the template (identified by
<tt>object</tt>). You can include the seconds with
<tt>:include_seconds</tt>.
</p>
<p>
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
<tt>true</tt>.
</p>
<p>
If anything is passed in the html_options hash it will be applied to every
select tag in the set.
</p>
<h4>Examples</h4>
<pre>
  # Creates a time select tag that, when POSTed, will be stored in the post variable in the sunrise attribute
  time_select(&quot;post&quot;, &quot;sunrise&quot;)

  # Creates a time select tag that, when POSTed, will be stored in the order variable in the submitted
  # attribute
  time_select(&quot;order&quot;, &quot;submitted&quot;)

  # Creates a time select tag that, when POSTed, will be stored in the mail variable in the sent_at attribute
  time_select(&quot;mail&quot;, &quot;sent_at&quot;)

  # Creates a time select tag with a seconds field that, when POSTed, will be stored in the post variables in
  # the sunrise attribute.
  time_select(&quot;post&quot;, &quot;start_time&quot;, :include_seconds =&gt; true)

  # Creates a time select tag with a seconds field that, when POSTed, will be stored in the entry variables in
  # the submission_time attribute.
  time_select(&quot;entry&quot;, &quot;submission_time&quot;, :include_seconds =&gt; true)

  # You can set the :minute_step to 15 which will give you: 00, 15, 30 and 45.
  time_select 'game', 'game_time', {:minute_step =&gt; 15}

  # Creates a time select tag with a custom prompt. Use :prompt =&gt; true for generic prompts.
  time_select(&quot;post&quot;, &quot;written_on&quot;, :prompt =&gt; {:hour =&gt; 'Choose hour', :minute =&gt; 'Choose minute', :second =&gt; 'Choose seconds'})
  time_select(&quot;post&quot;, &quot;written_on&quot;, :prompt =&gt; {:hour =&gt; true}) # generic prompt for hours
  time_select(&quot;post&quot;, &quot;written_on&quot;, :prompt =&gt; true) # generic prompts for all
</pre>
<p>
The selects are prepared for multi-parameter assignment to an Active Record
object.
</p>
<p>
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 all month choices are valid.
</p>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>