Class DateHelper

(line 34)

Description

AkActionViewHelper
   |
   --DateHelper

Located in File: /AkActionView/helpers/date_helper.php

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:

* <tt>:prefix</tt> - overwrites the default prefix of "date" used for the select names. So specifying "birthday" would give birthday[month] instead of date[month] if passed to the select_month method. * <tt>:include_blank</tt> - set to true if it should be possible to set an empty date. * <tt>:discard_type</tt> - set to true if you want to discard the type part of the select name. If set to true, the select_month method would use simply "date" (which can be overwritten using <tt>:prefix</tt>) instead of "date[month]".



Class Variables

Summary:

Class Constants

Summary:

Method Detail

Summary:
void datetime_select ( $object_name,  $column_name, [ $options = array()])
void date_select ( $object_name,  $column_name, [ $options = array()])
void distance_of_time_in_words ( $from_time, [ $to_time = 0], [ $include_seconds = false])
void distance_of_time_in_words_to_now ( $from_time, [ $include_seconds = false])
void locale_date ([ $iso_date = null])
void locale_date_time ([ $iso_date_time = null])
void select_date ([ $date = null], [ $options = array()])
void select_datetime ([ $datetime = null], [ $options = array()])
void select_day ( $date, [ $options = array()])
void select_hour ( $datetime, [ $options = array()])
void select_minute ( $datetime, [ $options = array()])
void select_month ([ $date = null], [ $options = array()])
void select_second ( $datetime, [ $options = array()])
void select_time ([ $datetime = null], [ $options = array()])
void select_year ([ $date = null], [ $options = array()])
void time_ago_in_words ( $from_time, [ $include_seconds = false])
void _add_one ( $number)
void _select_for ( $select_type,  $range,  $date_format,  $datetime, [ $options = array()], [ $unit_format_callback = '_leading_zero_on_single_digits'])
void _select_html ( $type,  $options, [ $prefix = null], [ $include_blank = false], [ $discard_type = false], [ $disabled = false])

Method datetime_select (line 164)

void datetime_select( $object_name, $column_name, [ $options = array()])

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 +column_name+) on an object assigned to the template (identified by +object+). Examples:

datetime_select("post", "written_on"); datetime_select("post", "written_on", array('start_year' => 1995));

The selects are prepared for multi-parameter assignment to an Active Record object.

Parameters

  • $object_name:
  • $column_name:
  • $options:

Info

Method date_select (line 121)

void date_select( $object_name, $column_name, [ $options = array()])

Returns a set of select tags (one for year, month, and day) pre-selected for accessing a specified date-based attribute (identified by

+column_name+) on an object assigned to the template (identified by +object+). It's possible to tailor the selects through the +options+ array, which accepts all the keys that each of the individual select builders do (like 'use_month_numbers' for select_month) as well as a range of discard options. The discard options are <tt>'discard_year'</tt>, <tt>'discard_month'</tt> and <tt>'discard_day'</tt>. Set to true, they'll drop the respective select. Discarding the month select will also automatically discard the day select. It's also possible to explicitly set the order of the tags using the <tt>'order'</tt> option with an array(<tt>'year'</tt>, <tt>'month'</tt> and <tt>'day')</tt> in the desired order.

Passing 'disabled' => true as part of the +options+ will make elements inaccessible for change.

NOTE: Discarded selects will default to 1. So if no month select is available, January will be assumed.

Examples:

$date_helper->date_select("post", "written_on"); $date_helper->date_select("post", "written_on", array('start_year' => 1995)); $date_helper->date_select("post", "written_on", array('start_year' => 1995, 'use_month_numbers' => true, 'discard_day' => true, 'include_blank' => true))); $date_helper->date_select("post", "written_on", array('order' => array('day', 'month', 'year'))); $date_helper->date_select("user", "birthday", array('order' => array('month', 'day')));

The selects are prepared for multi-parameter assignment to an Active Record object.

Parameters

  • $object_name:
  • $column_name:
  • $options:

Info

Method distance_of_time_in_words (line 48)

void distance_of_time_in_words( $from_time, [ $to_time = 0], [ $include_seconds = false])

Reports the approximate distance in time between two times given in seconds or in a valid ISO string like.

For example, if the distance is 47 minutes, it'll return "about 1 hour". See the source for the complete wording list.

Integers are interpreted as seconds. So, <tt>$date_helper->distance_of_time_in_words(50)</tt> returns "less than a minute".

Set <tt>include_seconds</tt> to true if you want more detailed approximations if distance < 1 minute

Parameters

  • $from_time:
  • $to_time:
  • $include_seconds:

Info

Method distance_of_time_in_words_to_now (line 92)

void distance_of_time_in_words_to_now( $from_time, [ $include_seconds = false])

Parameters

  • $from_time:
  • $include_seconds:

Info

Method locale_date (line 380)

void locale_date( [ $iso_date = null])

Converts an ISO date to current locale format

Parameters

  • $iso_date:

Info

Method locale_date_time (line 369)

void locale_date_time( [ $iso_date_time = null])

Converts an ISO date to current locale format

Parameters

  • $iso_date_time:

Info

Method select_date (line 202)

void select_date( [ $date = null], [ $options = array()])

Returns a set of html select-tags (one for year, month, and day) pre-selected with the +date+.

Parameters

  • $date:
  • $options:

Info

Method select_datetime (line 211)

void select_datetime( [ $datetime = null], [ $options = array()])

Returns a set of html select-tags (one for year, month, day, hour, and minute) pre-selected with the +datetime+.

Parameters

  • $datetime:
  • $options:

Info

Method select_day (line 263)

void select_day( $date, [ $options = array()])

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, 'day' by default.

Parameters

  • $date:
  • $options:

Info

Method select_hour (line 253)

void select_hour( $datetime, [ $options = array()])

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, 'hour' by default

Parameters

  • $datetime:
  • $options:

Info

Method select_minute (line 243)

void select_minute( $datetime, [ $options = array()])

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, 'minute' by default.

Parameters

  • $datetime:
  • $options:

Info

Method select_month (line 284)

void select_month( [ $date = null], [ $options = array()])

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's shown to the user) and the month numbers (1-12) are used as values (what's submitted to the server). It's also possible to use month numbers for the presentation instead of names -- set the <tt>use_month_numbers</tt> key in +options+ to true for this to happen. If you want both numbers and names, set the <tt>add_month_numbers</tt> key in +options+ to true. Examples:

$date_helper->select_month(Ak::getDate()); // Will use keys like "January", "March" $date_helper->select_month(Ak::getDate(), array('use_month_numbers' => true)); // Will use keys like "1", "3" $date_helper->select_month(Ak::getDate(), array('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.

Parameters

  • $date:
  • $options:

Info

Method select_second (line 232)

void select_second( $datetime, [ $options = array()])

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, 'second' by default.

Parameters

  • $datetime:
  • $options:

Info

Method select_time (line 220)

void select_time( [ $datetime = null], [ $options = array()])

Returns a set of html select-tags (one for hour and minute)

Parameters

  • $datetime:
  • $options:

Info

Method select_year (line 313)

void select_year( [ $date = null], [ $options = array()])

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 +options+. 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. Example:

$date_helper->select_year(Ak::getDate(), array('start_year' => 1992, 'end_year' => 2007)); // ascending year values $date_helper->select_year(Ak::getDate(), array('start_year' => 2005, 'end_year' => 1900)); // descending year values

Override the field name using the <tt>field_name</tt> option, 'year' by default.

Parameters

  • $date:
  • $options:

Info

Method time_ago_in_words (line 88)

void time_ago_in_words( $from_time, [ $include_seconds = false])

Like distance_of_time_in_words, but where <tt>to_time</tt> is fixed to <tt>timestamp()</tt>.

Parameters

  • $from_time:
  • $include_seconds:

Info

Method _add_one (line 359)

void _add_one( $number)

Parameters

  • $number:

Info

Method _leading_zero_on_single_digits (line 354)

void _leading_zero_on_single_digits( $number)

Parameters

  • $number:

Info

Method _select_for (line 326)

void _select_for( $select_type, $range, $date_format, $datetime, [ $options = array()], [ $unit_format_callback = '_leading_zero_on_single_digits'])

Parameters

  • $select_type:
  • $range:
  • $date_format:
  • $datetime:
  • $options:
  • $unit_format_callback:

Info

Method _select_html (line 345)

void _select_html( $type, $options, [ $prefix = null], [ $include_blank = false], [ $discard_type = false], [ $disabled = false])

Parameters

  • $type:
  • $options:
  • $prefix:
  • $include_blank:
  • $discard_type:
  • $disabled:

Info

Inherited Variables

Inherited Class Variable Summary

Inherited From Class AkActionViewHelper

AkActionViewHelper::$locales_namespace -

Inherited Methods

Inherited Method Summary

Inherited From Class AkActionViewHelper

AkActionViewHelper::AkActionViewHelper() -

AkActionViewHelper::addObject() -

AkActionViewHelper::getObject() -

AkActionViewHelper::setController() -

AkActionViewHelper::t() -



Documentation generated on Sat, 20 Oct 2007 00:23:17 +0200 by phpDocumentor 1.3.2