diff --git a/core/lib/Drupal/Core/Datetime/DateFormatter.php b/core/lib/Drupal/Core/Datetime/DateFormatter.php index 40b8621..5e81fce 100644 --- a/core/lib/Drupal/Core/Datetime/DateFormatter.php +++ b/core/lib/Drupal/Core/Datetime/DateFormatter.php @@ -211,14 +211,14 @@ public function formatInterval($interval, $granularity = 2, $langcode = NULL) { */ public function getSampleDateFormats($langcode = NULL, $timestamp = NULL, $timezone = NULL) { $language_code = $langcode ?: NULL; - $ts = $timestamp ?: REQUEST_TIME; - $tz = $timezone ?: NULL; + $timestamp = $timestamp ?: REQUEST_TIME; + $timezone = $timezone ?: NULL; // All date format characters for the PHP date() function. $date_characters = 'dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU'; $date_chars = str_split($date_characters); $date_elements = array_combine($date_chars, $date_chars); - return array_map(function($character) use ($ts, $tz, $language_code) { - return $this->format($ts, 'custom', $character, $tz, $language_code); + return array_map(function($character) use ($timestamp, $timezone, $language_code) { + return $this->format($timestamp, 'custom', $character, $timezone, $language_code); }, $date_elements); } diff --git a/core/modules/config_translation/src/FormElement/DateFormat.php b/core/modules/config_translation/src/FormElement/DateFormat.php index b541108..45aab74 100644 --- a/core/modules/config_translation/src/FormElement/DateFormat.php +++ b/core/modules/config_translation/src/FormElement/DateFormat.php @@ -27,29 +27,24 @@ public function getTranslationElement(LanguageInterface $translation_language, $ $description = $this->t('A user-defined date format. See the PHP manual for available options.', array('@url' => 'http://php.net/manual/function.date.php')); $format = $this->t('Displayed as %date_format', array('%date_format' => $date_formatter->format(REQUEST_TIME, 'custom', $translation_config))); - return array( + return [ '#type' => 'textfield', '#description' => $description, '#field_suffix' => ' ' . $format . '', - '#attributes' => array( + '#attributes' => [ 'data-drupal-date-formatter' => 'source', - ), - '#attached' => array( + ], + '#attached' => [ 'drupalSettings' => array('dateFormats' => $date_formatter->getSampleDateFormats($translation_language->getId())), - ), - - ) + parent::getTranslationElement($translation_language, $source_config, $translation_config); + ], + ] + parent::getTranslationElement($translation_language, $source_config, $translation_config); } /** * {@inheritdoc} */ public function getFormAttributes() { - return array( - '#attached' => array( - 'library' => array('system/drupal.system.date'), - ), - ); + return ['#attached' => ['library' => ['system/drupal.system.date']]]; } } diff --git a/core/modules/system/js/system.date.js b/core/modules/system/js/system.date.js index 98bb96e..fcab3ef 100644 --- a/core/modules/system/js/system.date.js +++ b/core/modules/system/js/system.date.js @@ -22,7 +22,7 @@ /** * Event handler that replaces date characters with value. * - * @param Object e + * @param {object} e */ function dateFormatHandler(e) { var baseValue = $(e.target).val() || '';