You are here

function views_handler_field_amazon_date::render in Amazon Product Advertisement API 7

Same name and namespace in other branches
  1. 6 includes/views_handler_field_amazon_date.inc \views_handler_field_amazon_date::render()
  2. 7.2 includes/views_handler_field_amazon_date.inc \views_handler_field_amazon_date::render()

Render the field.

Parameters

array $values: The values retrieved from the database.

Overrides views_handler_field_date::render

File

includes/views_handler_field_amazon_date.inc, line 20

Class

views_handler_field_amazon_date
A handler to provide proper displays for dates.

Code

function render($values) {
  $value = strtotime($this
    ->get_value($values));
  $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 = REQUEST_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);
    }
  }
}