You are here

function date_part_format in Date 7.3

Same name and namespace in other branches
  1. 7.2 date_api/date_api.module \date_part_format()

Helper function to get a format for a specific part of a date field.

Parameters

string $part: The date field part, either 'time' or 'date'.

string $format: A date format string.

Return value

string The date format for the given part.

1 call to date_part_format()
hook_date_combo_pre_validate_alter in ./date.api.php
Alter the date_combo element before the rest of the validation is run.

File

date_api/date_api.module, line 2316
This module will make the date API available to other modules.

Code

function date_part_format($part, $format) {
  switch ($part) {
    case 'date':
      return date_limit_format($format, array(
        'year',
        'month',
        'day',
      ));
    case 'time':
      return date_limit_format($format, array(
        'hour',
        'minute',
        'second',
      ));
    default:
      return date_limit_format($format, array(
        $part,
      ));
  }
}