function date_field_diff_view in Date 7.3
Same name and namespace in other branches
- 7.2 date.diff.inc \date_field_diff_view()
Diff field callback for parsing date fields comparative values.
File
- ./
date.diff.inc, line 11 - Provide diff field functions for the Date module.
Code
function date_field_diff_view($items, $context) {
$diff_items = array();
$display = $context['display'];
$display['settings']['format_type'] = $context['settings']['format_type'];
$display['settings']['fromto'] = $context['settings']['fromto'];
foreach ($items as $delta => $item) {
$date = date_formatter_process('date_default', $context['entity_type'], $context['entity'], $context['field'], $context['instance'], $context['language'], $item, $display);
switch ($display['settings']['fromto']) {
case 'both':
if ($date['value']['formatted'] != $date['value2']['formatted']) {
$diff_items[$delta] = t('@from to @to', array(
'@from' => $date['value']['formatted'],
'@to' => $date['value2']['formatted'],
));
}
else {
$diff_items[$delta] = $date['value']['formatted'];
}
break;
case 'value':
case 'value2':
$diff_items[$delta] = $date[$display['settings']['fromto']]['formatted'];
break;
}
}
return $diff_items;
}