function theme_date_format_interval in Date 5.2
Same name and namespace in other branches
- 5 date.module \theme_date_format_interval()
- 6.2 date/date.theme \theme_date_format_interval()
- 6 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 theme call to theme_date_format_interval()
- date_field_formatter in date/
date.module - Implementation of hook_field_formatter().
File
- date/
date.theme, line 126 - Theme functions.
Code
function theme_date_format_interval($field, $item, $dates, $node = NULL) {
// Time to compare dates to
$now = date_format(date_now(), 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 $dates['value']['interval'];
}
}