You are here

function datex_date_formatter_dates_alter in Datex 7.3

Same name and namespace in other branches
  1. 7.2 datex_date.inc \datex_date_formatter_dates_alter()

Implements hook_date_formatter_dates_alter().

File

./datex_date.inc, line 288
Provides support for date module.

Code

function datex_date_formatter_dates_alter(&$dates, $context) {
  $calendar = _datex_date_field_calendar($context);
  if (!$calendar) {
    return;
  }
  foreach ($dates as $index => &$date) {
    $timestamp = $date['local']['object']
      ->format('U');
    $tz = $date['local']['object']
      ->getTimezone();
    $copy = new DateObject('@' . $timestamp, $tz);
    _datex_fix_missing_granularity($copy, $context, $calendar
      ->getCalendarName());
    $calendar
      ->setTimestamp($copy
      ->getTimestamp());
    $calendar
      ->setTime((int) $date['local']['object']
      ->format('G'), (int) $date['local']['object']
      ->format('i'), (int) $date['local']['object']
      ->format('s'));
    $dates[$index]['formatted'] = $calendar
      ->format($context['format']);
  }
}