function theme_date_format_interval in Date 6.2
Same name and namespace in other branches
- 5.2 date/date.theme \theme_date_format_interval()
- 5 date.module \theme_date_format_interval()
- 6 date/date.theme \theme_date_format_interval()
Theme a format interval for a date element
Parameters
$field = the field settings: @param $node = node information, this is not always available and not always the full node, it depends on what value was provided to the formatter. Only the nid is always guaranteed to be available. @param $dates - an array of date information, see explanation for date_field_object for details. @return a formatted display
1 string reference to 'theme_date_format_interval'
- date_theme in date/
date.module - Implementation of hook_theme().
File
- date/
date.theme, line 175 - Theme functions.
Code
function theme_date_format_interval($element) {
$node = $element['#node'];
$field_name = $element['#field_name'];
$context = !empty($node->content) ? $node->content[$field_name]['#context'] : 'full';
$type_name = $element['#type_name'];
$fields = content_fields();
$field = $fields[$field_name];
$item = $element['#item'];
// Get the formatter settings, either the default settings for this node
// type or the View settings stored in $node->date_info.
$options = date_formatter_get_settings($field_name, $type_name, $context);
if (!empty($node->date_info) && !empty($node->date_info->formatter_settings)) {
$options = $node->date_info->formatter_settings;
}
// If date_id is set for this field and the delta doesn't match, don't display it.
if (!empty($node->date_id)) {
foreach ((array) $node->date_id as $key => $id) {
list($module, $nid, $field_name, $delta, $other) = explode('.', $id);
if ($field_name == $field['field_name'] && isset($item['#delta']) && $delta != $item['#delta']) {
return;
}
}
}
// If this is not coming from Views, it is the full node.
// If we aren't retrieving a specific value, adjust the node values
// to match the formatter settings, removing values we should not see.
if (!empty($node->content) && empty($node->date_id)) {
$node = date_prepare_node($node, $field, $type_name, $context, $options);
// Did the current value get removed by formatter settings?
if (empty($node->{$field_name}[$item['#delta']])) {
return;
}
// Adjust the $element values to match the changes.
$element['#node'] = $node;
}
$dates = date_formatter_process($element);
return theme('date_time_ago', $dates['value']['local']['object'], $dates['value2']['local']['object']);
}