You are here

function calendar_systems_format_date_alter in Calendar Systems 7

Same name and namespace in other branches
  1. 8 calendar_systems.module \calendar_systems_format_date_alter()
  2. 7.2 calendar_systems.module \calendar_systems_format_date_alter()

Implementation of format_date_alter hook/call Altering out of format_date function

File

./calendar_systems.module, line 103
Contains Calendar Systems hook implementations and helpers.

Code

function calendar_systems_format_date_alter(&$formatted_date, &$context) {

  // Calendar systems specific code
  $calendar_name = calendar_systems_get_calendar_system_name();
  if ($calendar_name != 'default' && ($calendar = calendar_systems_get_calendar_instance())) {
    $calendar
      ->setTimeZoneOffset($context['date_time']
      ->getOffset());
    $format = $calendar
      ->timestampToStr($context['format'], $context['date_time']
      ->getTimestamp() + $context['date_time']
      ->getOffset());
    $format = preg_replace('%[-+][0-9]{4}%', $context['date_time']
      ->format('O'), $format);

    // Pass the langcode to _format_date_callback().
    _format_date_callback(NULL, $context['langcode']);

    // Translate the marked sequences.
    $formatted_date = preg_replace_callback('/\\xEF([AaeDlMTF]?)(.*?)\\xFF/', '_format_date_callback', $format);
  }
}