You are here

protected function field_timer_text_base::renderItem in Field Timer 7.2

Render field item.

2 calls to field_timer_text_base::renderItem()
field_timer_text_base::renderItems in includes/field_timer_text.inc
Render field items.
field_timer_text_date_field_base::renderItems in includes/field_timer_text.inc
@inheritdoc

File

includes/field_timer_text.inc, line 128
Contains help classes to perform field_timer_text formatter related actions.

Class

field_timer_text_base
Base class for field_timer_text formatter.

Code

protected function renderItem($type, $granularity_type, $granularity_option, $timestamp) {
  $time = '';

  // Check what we should display - timer or countdown.
  switch ($type) {
    case 'auto':
      $interval = REQUEST_TIME - $timestamp;
      $sign = $interval > 0 ? '+' : '-';
      $time = $sign . $this
        ->formatInterval(abs($interval), $granularity_type, $granularity_option);
      break;
    case 'timer':
      $time = $this
        ->formatInterval(REQUEST_TIME - $timestamp, $granularity_type, $granularity_option);
      break;
    case 'countdown':
      $time = $this
        ->formatInterval($timestamp - REQUEST_TIME, $granularity_type, $granularity_option);
      break;
  }
  return $time;
}