You are here

function theme_date_time_ago in Date 6.2

Same name and namespace in other branches
  1. 8 date_api/theme/theme.inc \theme_date_time_ago()
  2. 7.3 date_api/theme/theme.inc \theme_date_time_ago()
  3. 7 date_api/theme/theme.inc \theme_date_time_ago()
  4. 7.2 date_api/theme/theme.inc \theme_date_time_ago()
1 theme call to theme_date_time_ago()
theme_date_format_interval in date/date.theme
Theme a format interval for a date element

File

theme/theme.inc, line 393
Theme functions for Date.

Code

function theme_date_time_ago($start_date, $end_date, $interval = 2) {

  // If no date is sent, then return nothing
  if (empty($start_date) || empty($end_date)) {
    return NULL;
  }

  // Time to compare dates to
  $now = date_format(date_now(), DATE_FORMAT_DATETIME);
  $start = date_format($start_date, DATE_FORMAT_DATETIME);
  $end = date_format($end_date, DATE_FORMAT_DATETIME);

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

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