You are here

function date_sql_handler::date_parts in Date 6

Same name and namespace in other branches
  1. 5.2 date_api_sql.inc \date_sql_handler::date_parts()
  2. 6.2 date_api_sql.inc \date_sql_handler::date_parts()
  3. 7.3 date_api/date_api_sql.inc \date_sql_handler::date_parts()
  4. 7 date_api/date_api_sql.inc \date_sql_handler::date_parts()
  5. 7.2 date_api/date_api_sql.inc \date_sql_handler::date_parts()

An array of all date parts, optionally limited to an array of allowed parts.

1 call to date_sql_handler::date_parts()
date_sql_handler::complete_date in ./date_api_sql.inc
Create a complete datetime value out of an incomplete array of selected values.

File

./date_api_sql.inc, line 445

Class

date_sql_handler
A class to manipulate date SQL.

Code

function date_parts($limit = NULL) {
  $parts = array(
    'year' => t('Year'),
    'month' => t('Month'),
    'day' => t('Day'),
    'hour' => t('Hour'),
    'minute' => t('Minute'),
    'second' => t('Second'),
  );
  if (!empty($limit)) {
    $last = FALSE;
    foreach ($parts as $key => $part) {
      if ($last) {
        unset($parts[$key]);
      }
      if ($key == $limit) {
        $last = TRUE;
      }
    }
  }
  return $parts;
}