You are here

function theme_date_format_interval in Date 6

Same name and namespace in other branches
  1. 5.2 date/date.theme \theme_date_format_interval()
  2. 5 date.module \theme_date_format_interval()
  3. 6.2 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 83
Theme functions.

Code

function theme_date_format_interval($element) {
  $dates = date_formatter_process($element);

  // Time to compare dates to
  $now = date_format(date_make_date('now', date_default_timezone()), DATE_FORMAT_DATETIME);
  $start = $dates['value']['local']['datetime'];
  $end = $dates['value2']['local']['datetime'];

  // 1) The date is entirely in the future
  if ($now < $start) {
    return t('!time from now', array(
      '!time' => $dates['value']['interval'],
    ));
  }
  elseif ($now > $start && $now <= $end) {

    //return t('Started !time ago', array('!time' => $dates['value']['interval']));
    return t('ongoing');
  }
  else {
    return t('!time ago', array(
      '!time' => $dates['value']['interval'],
    ));
  }
}