1 date.field.inc | date_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) |
Implements hook_field_load().
File
- core/
modules/ date/ date.field.inc, line 379 - Field hooks to implement a date field.
Code
function date_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
$timezone_db = date_get_timezone_db($field['settings']['tz_handling']);
$db_format = date_type_format($field['type']);
$process = date_process_values($field);
foreach ($entities as $id => $entity) {
foreach ($items[$id] as $delta => &$item) {
// If the file does not exist, mark the entire item as empty.
if (is_array($item)) {
$timezone = isset($item['timezone']) ? $item['timezone'] : '';
$item['timezone'] = date_get_timezone($field['settings']['tz_handling'], $timezone);
$item['timezone_db'] = $timezone_db;
$item['date_type'] = $field['type'];
if (!empty($field['settings']['cache_enabled']) && ($delta < $field['settings']['cache_count'] || $field['settings']['cache_count'] == 0)) {
foreach ($process as $processed) {
if (!empty($item[$processed])) {
$date = new BackdropDateTime($item[$processed], $item['timezone_db'], $db_format);
$date->limitGranularity($field['settings']['granularity']);
$item['db'][$processed] = $date;
}
}
if (!empty($item['db']['value']) && empty($item['db']['value2'])) {
$item['db']['value2'] = $item['db']['value'];
}
}
}
}
}
}