You are here

function theme_date_display_interval in Date 7.2

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 date.theme \theme_date_display_interval()

Returns HTML for a date element formatted as an interval.

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 386
Theme functions.

Code

function theme_date_display_interval($variables) {
  $entity = $variables['entity'];
  $options = $variables['display']['settings'];
  $dates = $variables['dates'];
  $attributes = $variables['attributes'];

  // 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'],
    'interval_display' => $options['interval_display'],
    'use_end_date' => !empty($options['use_end_date']) ? $options['use_end_date'] : FALSE,
  );
  if ($return = theme('date_time_ago', $time_ago_vars)) {
    return '<span class="date-display-interval"' . drupal_attributes($attributes) . ">{$return}</span>";
  }
  else {
    return '';
  }
}