class views_handler_field_system_info_datestamp in Views System 6.3
Same name and namespace in other branches
- 6.2 views/handlers/views_handler_field_system_info_datestamp.inc \views_handler_field_system_info_datestamp
- 7.3 views/handlers/views_handler_field_system_info_datestamp.inc \views_handler_field_system_info_datestamp
Renders the date stamp field of the system item.
Hierarchy
- class \views_handler_field_system_info_datestamp extends \views_handler_field_date
Expanded class hierarchy of views_handler_field_system_info_datestamp
1 string reference to 'views_handler_field_system_info_datestamp'
- views_system_views_data_alter in views/
views_system.views.inc - Implementation of hook_views_data_alter().
File
- views/
handlers/ views_handler_field_system_info_datestamp.inc, line 14 - Views field handler for the views_system module.
View source
class views_handler_field_system_info_datestamp extends views_handler_field_date {
function render($values) {
$info = unserialize($values->{$this->field_alias});
$value = isset($info['datestamp']) ? $info['datestamp'] : NULL;
$format = $this->options['date_format'];
if (in_array($format, array(
'custom',
'raw time ago',
'time ago',
'raw time span',
'time span',
))) {
$custom_format = $this->options['custom_date_format'];
}
if (!$value) {
return theme('views_nodate');
}
else {
$time_diff = time() - $value;
// will be positive for a datetime in the past (ago), and negative for a datetime in the future (hence)
switch ($format) {
case 'raw time ago':
return format_interval($time_diff, is_numeric($custom_format) ? $custom_format : 2);
case 'time ago':
return t('%time ago', array(
'%time' => format_interval($time_diff, is_numeric($custom_format) ? $custom_format : 2),
));
case 'raw time span':
return ($time_diff < 0 ? '-' : '') . format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2);
case 'time span':
return t($time_diff < 0 ? '%time hence' : '%time ago', array(
'%time' => format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2),
));
case 'custom':
if ($custom_format == 'r') {
return format_date($value, $format, $custom_format, NULL, 'en');
}
return format_date($value, $format, $custom_format);
default:
return format_date($value, $format);
}
}
}
}