You are here

function _datex_date_field_granularity in Datex 7.3

Extract granularity from element (probably a form element).

2 calls to _datex_date_field_granularity()
_datex_date_field_calendar in ./datex_date.inc
Create a datex-calendar based on field config and the schema set for it.
_datex_date_field_has_granularity in ./datex_date.inc
Check and see if a field is configured to have a granularity or not.

File

./datex_date.inc, line 31
Provides support for date module.

Code

function _datex_date_field_granularity($element) {
  if (isset($element['#granularity'])) {
    return $element['#granularity'];
  }
  elseif (isset($element['field']['settings']['granularity'])) {
    $granularities = array_values($element['field']['settings']['granularity']);
    foreach ($granularities as $index => $value) {
      if ($value === 0) {
        unset($granularities[$index]);
      }
    }
    return $granularities;
  }
  elseif (isset($element['#field']['settings']['granularity'])) {
    $granularities = array_values($element['#field']['settings']['granularity']);
    foreach ($granularities as $index => $value) {
      if ($value === 0) {
        unset($granularities[$index]);
      }
    }
    return $granularities;
  }
  else {
    return [
      [],
      [],
    ];
  }
}