function date_field_update in Date 7
Same name and namespace in other branches
- 8 date.field.inc \date_field_update()
- 7.3 date.field.inc \date_field_update()
- 7.2 date.field.inc \date_field_update()
Implements hook_field_update().
2 calls to date_field_update()
- date_field_insert in ./
date.field.inc - Implements hook_field_insert().
- date_field_presave in ./
date.field.inc - Implements hook_field_presave().
File
- ./
date.field.inc, line 357 - Field hooks to implement a date field.
Code
function date_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
$field_name = $field['field_name'];
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;
foreach ($values as $delta => $item) {
if (is_array($item)) {
// Special case for ISO dates which may have been given artificial values for
// some date parts to make them into valid dates.
// @TODO Decide how to replace the date_limit_value() function.
if (!empty($item['value']) && $field['type'] == DATE_ISO) {
//$items[$delta]['value'] = date_limit_value($items[$delta]['value'], date_granularity($field), $field['type']);
if ($field['settings']['todate']) {
//$items[$delta]['value2'] = date_limit_value($items[$delta]['value2'], date_granularity($field), $field['type']);
}
}
}
}
$entity->{$field['field_name']}[$langcode] = $items;
}