function theme_date_time_ago in Date 7
Same name and namespace in other branches
- 8 date_api/theme/theme.inc \theme_date_time_ago()
- 6.2 theme/theme.inc \theme_date_time_ago()
- 7.3 date_api/theme/theme.inc \theme_date_time_ago()
- 7.2 date_api/theme/theme.inc \theme_date_time_ago()
1 theme call to theme_date_time_ago()
- theme_date_display_interval in ./
date.theme - Theme a format interval for a date element
File
- date_api/
theme/ theme.inc, line 169 - Theme files for Date API.
Code
function theme_date_time_ago($vars) {
$start_date = $vars['start_date'];
$end_date = $vars['end_date'];
$interval = !empty($vars['interval']) ? $vars['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);
}
}