You are here

function hook_date_formatter_dates_alter in Date 7.3

Same name and namespace in other branches
  1. 8 date.api.php \hook_date_formatter_dates_alter()
  2. 7.2 date.api.php \hook_date_formatter_dates_alter()

Alter the dates array created by date_formatter_process().

Parameters

array $dates: The $dates array created by the Date module.

array $context: An associative array containing the following keys:

  • field: The $field array.
  • instance: The $instance array.
  • format: The string $format.
  • entity_type: The $entity_type.
  • entity: The $entity object.
  • langcode: The string $langcode.
  • item: The $item array.
  • display: The $display array.
1 function implements hook_date_formatter_dates_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

date_all_day_date_formatter_dates_alter in date_all_day/date_all_day.module
Implements hook_date_formatter_dates_alter().
1 invocation of hook_date_formatter_dates_alter()
date_formatter_process in ./date.module
Helper function for creating formatted date arrays from a formatter.

File

./date.api.php, line 71
Hooks provided by the Date module.

Code

function hook_date_formatter_dates_alter(array &$dates, array $context) {
  $field = $context['field'];
  $instance = $context['instance'];
  $format = $context['format'];
  $entity_type = $context['entity_type'];
  $entity = $context['entity'];
  $date1 = $dates['value']['local']['object'];
  $date2 = $dates['value2']['local']['object'];
  $is_all_day = date_all_day_field($field, $instance, $date1, $date2);
  $all_day1 = '';
  $all_day2 = '';
  if ($format != 'format_interval' && $is_all_day) {
    $all_day1 = theme('date_all_day', array(
      'field' => $field,
      'instance' => $instance,
      'which' => 'date1',
      'date1' => $date1,
      'date2' => $date2,
      'format' => $format,
      'entity_type' => $entity_type,
      'entity' => $entity,
    ));
    $all_day2 = theme('date_all_day', array(
      'field' => $field,
      'instance' => $instance,
      'which' => 'date2',
      'date1' => $date1,
      'date2' => $date2,
      'format' => $format,
      'entity_type' => $entity_type,
      'entity' => $entity,
    ));
    $dates['value']['formatted_time'] = theme('date_all_day_label');
    $dates['value2']['formatted_time'] = theme('date_all_day_label');
    $dates['value']['formatted'] = $all_day1;
    $dates['value2']['formatted'] = $all_day2;
  }
}