public function date_sql_handler::date_parts in Date 7.2
Same name and namespace in other branches
- 5.2 date_api_sql.inc \date_sql_handler::date_parts()
- 6.2 date_api_sql.inc \date_sql_handler::date_parts()
- 6 date_api_sql.inc \date_sql_handler::date_parts()
- 7.3 date_api/date_api_sql.inc \date_sql_handler::date_parts()
- 7 date_api/date_api_sql.inc \date_sql_handler::date_parts()
An array of all date parts,
Parameters
bool $limit: Limit to an array of allowed parts.
2 calls to date_sql_handler::date_parts()
- date_sql_handler::complete_date in date_api/
date_api_sql.inc - Create a complete date/time value out of an incomplete array of values.
- date_sql_handler::granularity_form in date_api/
date_api_sql.inc - @todo Document this.
File
- date_api/
date_api_sql.inc, line 738 - SQL helper for Date API.
Class
- date_sql_handler
- A class to manipulate date SQL.
Code
public function date_parts($limit = NULL) {
$parts = array(
'year' => t('Year', array(), array(
'context' => 'datetime',
)),
'month' => t('Month', array(), array(
'context' => 'datetime',
)),
'day' => t('Day', array(), array(
'context' => 'datetime',
)),
'hour' => t('Hour', array(), array(
'context' => 'datetime',
)),
'minute' => t('Minute', array(), array(
'context' => 'datetime',
)),
'second' => t('Second', array(), array(
'context' => 'datetime',
)),
);
if (!empty($limit)) {
$last = FALSE;
foreach ($parts as $key => $part) {
if ($last) {
unset($parts[$key]);
}
if ($key == $limit) {
$last = TRUE;
}
}
}
return $parts;
}