diff --git a/core/includes/common.inc b/core/includes/common.inc index edd7c2d..52c95b1 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -1930,7 +1930,19 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL // Call date_format(). $settings = array('langcode' => $langcode); - return $date_time->format($format, $settings); + $formatted_date = $date_time->format($format, $settings); + + $context = array( + 'date_time' => $date_time, + 'timestamp' => $timestamp, + 'type' => $type, + 'format' => $format, + 'timezone' => $timezone, + 'langcode' => $langcode, + ); + drupal_alter('format_date', $formatted_date, $context); + + return $formatted_date; } /** diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 5e3582f..c1a1a3b 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -3950,6 +3950,29 @@ function hook_filetransfer_info_alter(&$filetransfer_info) { } /** + * Alter the formatted date. + * + * A module may implement this hook in order to alter the formatted date string. + * + * @param string $formatted_date + * The formatted date. + * @param array $context + * An associative array containing: + * - date_time: The DrupalDateTime object with the date to format. + * - timestamp: The UNIX timestamp to format. + * - type: The format to use as passed to format_date(). + * - format: If type is 'custom', a PHP date format string suitable for input + * to date(). + * - timezone: The time zone as passed to format_date(). + * - langcode: The language code as passed to format_date(). + * + * @see format_date() + */ +function hook_format_date_alter(&$formatted_date, array $context) { + $formatted_date .= ' ' . $context['timezone']; +} + +/** * @} End of "addtogroup hooks". */