You are here

function date_granularity in Date 7.3

Same name and namespace in other branches
  1. 8 date.module \date_granularity()
  2. 5.2 date/date.module \date_granularity()
  3. 6.2 date/date.module \date_granularity()
  4. 6 date/date.module \date_granularity()
  5. 7 date.module \date_granularity()
  6. 7.2 date.module \date_granularity()

Retrieves the granularity for a field.

$field['settings']['granularity'] will contain an array like ('hour' => 'hour', 'month' => 0) where the values turned on return their own names and the values turned off return a zero need to reconfigure this into simple array of the turned on values.

Parameters

array $field: The field array.

1 call to date_granularity()
date_formatter_process in ./date.module
Helper function for creating formatted date arrays from a formatter.

File

./date.module, line 361

Code

function date_granularity(array $field) {
  if (!is_array($field) || !is_array($field['settings']['granularity'])) {
    $granularity = drupal_map_assoc(array(
      'year',
      'month',
      'day',
    ));
    $field['settings']['granularity'] = $granularity;
  }
  return array_values(array_filter($field['settings']['granularity']));
}