1 date.field.inc date_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items)

Implements hook_field_insert().

File

core/modules/date/date.field.inc, line 490
Field hooks to implement a date field.

Code

function date_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
  if (empty($items)) {
    return;
  }
  // Add some information needed to interpret token values.
  $values = $items;
  foreach ($values as $delta => $item) {
    $timezone = isset($item['timezone']) ? $item['timezone'] : '';
    if (is_array($item)) {
      $items[$delta]['timezone'] = date_get_timezone($field['settings']['tz_handling'], $timezone);
      $items[$delta]['timezone_db'] = date_get_timezone_db($field['settings']['tz_handling']);
      $items[$delta]['date_type'] = $field['type'];
    }
  }
  $entity->{$field['field_name']}[$langcode] = $items;
}