1 date_sql_handler.inc | date_sql_handler::date_parts($limit = NULL) |
An array of all date parts, optionally limited to an array of allowed parts.
File
- core/
modules/ date/ views/ date_sql_handler.inc, line 415 - SQL helper for Date API.
Class
- date_sql_handler
- A class to manipulate date SQL.
Code
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;
}