You are here

function theme_date_display_interval in Date 7

Same name and namespace in other branches
  1. 8 date.theme \theme_date_display_interval()
  2. 7.3 date.theme \theme_date_display_interval()
  3. 7.2 date.theme \theme_date_display_interval()

Theme a format interval for a date element

Parameters

$field = the field settings: @param $entity = 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 theme call to theme_date_display_interval()
date_field_formatter_view in ./date.field.inc
Implements hook_field_formatter_view().

File

./date.theme, line 182
Theme functions.

Code

function theme_date_display_interval($vars) {
  $entity_type = $vars['entity_type'];
  $entity = $vars['entity'];
  $field = $vars['field'];
  $instance = $vars['instance'];
  $langcode = $vars['langcode'];
  $item = $vars['item'];
  $delta = $vars['delta'];
  $display = $vars['display'];
  $field_name = $field['field_name'];
  $options = $display['settings'];
  $dates = $vars['dates'];
  $formatter = $display['type'];

  // Get the formatter settings, either the default settings for this node
  // type or the View settings stored in $entity->date_info.
  if (!empty($entity->date_info) && !empty($entity->date_info->formatter_settings)) {
    $options = $entity->date_info->formatter_settings;
  }
  $time_ago_vars = array(
    'start_date' => $dates['value']['local']['object'],
    'end_date' => $dates['value2']['local']['object'],
    'interval' => $options['interval'],
  );
  return theme('date_time_ago', $time_ago_vars);
}