[ Index ]

PHP Cross Reference of Akelos Framework

title

Body

[close]

/AkActionView/helpers/ -> date_helper.php (summary)

(no description)

Author: Bermi Ferrer
Copyright: Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org
License: GNU Lesser General Public License
File Size: 400 lines (20 kb)
Included or required: 3 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

DateHelper:: (20 methods):
  distance_of_time_in_words()
  time_ago_in_words()
  distance_of_time_in_words_to_now()
  date_select()
  datetime_select()
  select_date()
  select_datetime()
  select_time()
  select_second()
  select_minute()
  select_hour()
  select_day()
  select_month()
  select_year()
  _select_for()
  _select_html()
  _leading_zero_on_single_digits()
  _add_one()
  locale_date_time()
  locale_date()


Class: DateHelper  - X-Ref

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]".
distance_of_time_in_words($from_time, $to_time = 0, $include_seconds = false)   X-Ref
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

time_ago_in_words($from_time, $include_seconds = false)   X-Ref
Like distance_of_time_in_words, but where <tt>to_time</tt> is fixed to <tt>timestamp()</tt>.


distance_of_time_in_words_to_now($from_time, $include_seconds = false)   X-Ref
No description

date_select($object_name, $column_name, $options = array()   X-Ref
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.

datetime_select($object_name, $column_name, $options = array()   X-Ref
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.

select_date($date = null, $options = array()   X-Ref
Returns a set of html select-tags (one for year, month, and day) pre-selected with the +date+.


select_datetime($datetime = null, $options = array()   X-Ref
Returns a set of html select-tags (one for year, month, day, hour, and minute) pre-selected with the +datetime+.


select_time($datetime = null, $options = array()   X-Ref
Returns a set of html select-tags (one for hour and minute)


select_second($datetime, $options = array()   X-Ref
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.


select_minute($datetime, $options = array()   X-Ref
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.


select_hour($datetime, $options = array()   X-Ref
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


select_day($date, $options = array()   X-Ref
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.


select_month($date=null, $options = array()   X-Ref
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.

select_year($date = null, $options = array()   X-Ref
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.

_select_for($select_type, $range, $date_format, $datetime, $options = array()   X-Ref
No description

_select_html($type, $options, $prefix = null, $include_blank = false, $discard_type = false, $disabled = false, $date_blank = false)   X-Ref
No description

_leading_zero_on_single_digits($number)   X-Ref
No description

_add_one($number)   X-Ref
No description

locale_date_time($iso_date_time = null)   X-Ref
Converts an ISO date to current locale format


locale_date($iso_date = null)   X-Ref
Converts an ISO date to current locale format




Generated: Mon Oct 27 12:43:49 2008 Cross-referenced by PHPXref 0.6