class views_handler_field_amazon_date in Amazon Product Advertisement API 6
Same name and namespace in other branches
- 7.2 includes/views_handler_field_amazon_date.inc \views_handler_field_amazon_date
- 7 includes/views_handler_field_amazon_date.inc \views_handler_field_amazon_date
A handler to provide proper displays for dates.
Hierarchy
- class \views_handler_field_amazon_date extends \views_handler_field_date
Expanded class hierarchy of views_handler_field_amazon_date
2 string references to 'views_handler_field_amazon_date'
- amazon_views_handlers in includes/
amazon.views.inc - Implementation of hook_views_handlers()
- _amazon_make_simple_date_field in includes/
amazon.views.inc
File
- includes/
views_handler_field_amazon_date.inc, line 7
View source
class views_handler_field_amazon_date extends views_handler_field_date {
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$time = time();
$form['date_format']['#options'] = array(
'default' => format_date($time, 'custom', 'Y-m-d'),
'custom' => t('Custom'),
);
}
function render($values) {
$value = strtotime($values->{$this->field_alias});
$format = $this->options['date_format'];
$default_format = 'Y-m-d';
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 'custom':
return format_date($value, $format, $custom_format);
default:
return format_date($value, 'custom', $default_format);
}
}
}
}