You are here

function date_granularity_format in Date 7.3

Same name and namespace in other branches
  1. 6.2 date_api.module \date_granularity_format()
  2. 7 date_api/date_api.module \date_granularity_format()
  3. 7.2 date_api/date_api.module \date_granularity_format()

Constructs a valid DATETIME format string for the granularity of an item.

@todo This function is no longer used as of http://drupalcode.org/project/date.git/commit/07efbb5.

File

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

Code

function date_granularity_format($granularity) {
  if (is_array($granularity)) {
    $granularity = date_granularity_precision($granularity);
  }
  $format = 'Y-m-d H:i:s';
  switch ($granularity) {
    case 'year':
      return substr($format, 0, 1);
    case 'month':
      return substr($format, 0, 3);
    case 'day':
      return substr($format, 0, 5);
    case 'hour':
      return substr($format, 0, 7);
    case 'minute':
      return substr($format, 0, 9);
    default:
      return $format;
  }
}