function theme_date_format_interval in Date 5
Same name and namespace in other branches
- 5.2 date/date.theme \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
Useful values: $field['type_name'] - the content type $field['type'] - the field type $node->nid - the node nid, get other node values using node_load($node->nid) $dates['value']['object']->local->timestamp - the local timestamp for the From date $dates['value2']['object']->local->timestamp - the local timestamp for the To date $dates['value']['object']->db->timestamp - the timestamp of the From date database (GMT) value $dates['value2']['object']->db->timestamp - the timestamp of the To date database (GMT) alue
1 theme call to theme_date_format_interval()
- theme_date_formatter in ./
date.module - Theme date formatter.
File
- ./
date.module, line 843 - Defines a date/time field type.
Code
function theme_date_format_interval($field, $dates, $node = NULL) {
global $user;
switch ($field['tz_handling']) {
case 'date':
$adj = $dates['value']['object']->local->offset;
break;
case 'user':
if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
$adj = $user->timezone;
}
else {
$adj = variable_get('date_default_timezone', 0);
}
break;
case 'none':
$adj = 0;
break;
default:
$adj = variable_get('date_default_timezone', 0);
}
$now = date_time() + $adj;
// Pull timestamps out of date objects.
$timestamp1 = $dates['value']['object']->db->timestamp + $adj;
$timestamp2 = ($dates['value2']['object']->db->timestamp ? $dates['value2']['object']->db->timestamp : $timestamp1) + $adj;
// 1) The date is entirely in the future
if ($now < $timestamp1) {
return t('!time', array(
'!time' => format_interval($timestamp1 - $now),
));
}
elseif ($now > $timestamp1 && $now <= $timestamp2) {
//return t('Started !time ago', array('!time' => format_interval($now - $timestamp1)));
return t('ongoing');
}
else {
return t('!time ago', array(
'!time' => format_interval($now - $timestamp2),
));
}
}