Loading core/lib/Drupal/Core/Datetime/TimeZoneFormHelper.php +36 −23 Original line number Diff line number Diff line Loading @@ -18,15 +18,13 @@ class TimeZoneFormHelper { * * @param bool $blank * (optional) If TRUE, prepend an empty time zone option to the array. * @param bool $grouped * (optional) Whether the timezones should be grouped by region. * * @return array * An array or nested array containing time zones, keyed by the system name. * The keys are valid time zone identifiers provided by * \DateTimeZone::listIdentifiers() */ public static function getOptionsList(bool $blank = FALSE, bool $grouped = FALSE): array { public static function getOptionsList(bool $blank = FALSE): array { $zonelist = \DateTimeZone::listIdentifiers(); $zones = $blank ? ['' => new TranslatableMarkup('- None selected -')] : []; foreach ($zonelist as $zone) { Loading @@ -34,7 +32,26 @@ public static function getOptionsList(bool $blank = FALSE, bool $grouped = FALSE } // Sort the translated time zones alphabetically. asort($zones); if ($grouped) { return $zones; } /** * Generate an array of time zones names grouped by region. * * This method retrieves the list of IANA time zones names that PHP is * configured to use, for display to users. It does not return the backward * compatible names (i.e., the ones defined in the back-zone file). * * @param bool $blank * (optional) If TRUE, prepend an empty time zone option to the array. * * @return array * An nested array containing time zones, keyed by the system name. The keys * are valid time zone identifiers provided by * \DateTimeZone::listIdentifiers() */ public static function getOptionsListByRegion(bool $blank = FALSE): array { $zones = static::getOptionsList($blank); $grouped_zones = []; foreach ($zones as $key => $value) { $split = explode('/', $value); Loading @@ -52,11 +69,7 @@ public static function getOptionsList(bool $blank = FALSE, bool $grouped = FALSE asort($grouped_zones[$key]); } } $zones = $grouped_zones; } return $zones; return $grouped_zones; } } core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php +1 −1 Original line number Diff line number Diff line Loading @@ -201,7 +201,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) { $form['timezone'] = [ '#type' => 'select', '#title' => $this->t('Time zone'), '#options' => ['' => $this->t('- Default site/user time zone -')] + TimeZoneFormHelper::getOptionsList(FALSE, TRUE), '#options' => ['' => $this->t('- Default site/user time zone -')] + TimeZoneFormHelper::getOptionsListByRegion(), '#default_value' => $this->getSetting('timezone'), ]; Loading core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php +1 −1 Original line number Diff line number Diff line Loading @@ -208,7 +208,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'select', '#title' => $this->t('Default time zone'), '#default_value' => $default_timezone, '#options' => TimeZoneFormHelper::getOptionsList(FALSE, TRUE), '#options' => TimeZoneFormHelper::getOptionsListByRegion(), '#weight' => 5, '#attributes' => ['class' => ['timezone-detect']], '#access' => empty($install_state['config_install_path']), Loading core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php +1 −1 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) { '#type' => 'select', '#title' => $this->t('Time zone override'), '#description' => $this->t('The time zone selected here will always be used'), '#options' => TimeZoneFormHelper::getOptionsList(TRUE, TRUE), '#options' => TimeZoneFormHelper::getOptionsListByRegion(TRUE), '#default_value' => $this->getSetting('timezone_override'), ]; Loading core/modules/system/src/Form/RegionalForm.php +1 −1 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $system_date = $this->config('system.date'); // Date settings: $zones = TimeZoneFormHelper::getOptionsList(FALSE, TRUE); $zones = TimeZoneFormHelper::getOptionsListByRegion(); $form['locale'] = [ '#type' => 'details', Loading Loading
core/lib/Drupal/Core/Datetime/TimeZoneFormHelper.php +36 −23 Original line number Diff line number Diff line Loading @@ -18,15 +18,13 @@ class TimeZoneFormHelper { * * @param bool $blank * (optional) If TRUE, prepend an empty time zone option to the array. * @param bool $grouped * (optional) Whether the timezones should be grouped by region. * * @return array * An array or nested array containing time zones, keyed by the system name. * The keys are valid time zone identifiers provided by * \DateTimeZone::listIdentifiers() */ public static function getOptionsList(bool $blank = FALSE, bool $grouped = FALSE): array { public static function getOptionsList(bool $blank = FALSE): array { $zonelist = \DateTimeZone::listIdentifiers(); $zones = $blank ? ['' => new TranslatableMarkup('- None selected -')] : []; foreach ($zonelist as $zone) { Loading @@ -34,7 +32,26 @@ public static function getOptionsList(bool $blank = FALSE, bool $grouped = FALSE } // Sort the translated time zones alphabetically. asort($zones); if ($grouped) { return $zones; } /** * Generate an array of time zones names grouped by region. * * This method retrieves the list of IANA time zones names that PHP is * configured to use, for display to users. It does not return the backward * compatible names (i.e., the ones defined in the back-zone file). * * @param bool $blank * (optional) If TRUE, prepend an empty time zone option to the array. * * @return array * An nested array containing time zones, keyed by the system name. The keys * are valid time zone identifiers provided by * \DateTimeZone::listIdentifiers() */ public static function getOptionsListByRegion(bool $blank = FALSE): array { $zones = static::getOptionsList($blank); $grouped_zones = []; foreach ($zones as $key => $value) { $split = explode('/', $value); Loading @@ -52,11 +69,7 @@ public static function getOptionsList(bool $blank = FALSE, bool $grouped = FALSE asort($grouped_zones[$key]); } } $zones = $grouped_zones; } return $zones; return $grouped_zones; } }
core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php +1 −1 Original line number Diff line number Diff line Loading @@ -201,7 +201,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) { $form['timezone'] = [ '#type' => 'select', '#title' => $this->t('Time zone'), '#options' => ['' => $this->t('- Default site/user time zone -')] + TimeZoneFormHelper::getOptionsList(FALSE, TRUE), '#options' => ['' => $this->t('- Default site/user time zone -')] + TimeZoneFormHelper::getOptionsListByRegion(), '#default_value' => $this->getSetting('timezone'), ]; Loading
core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php +1 −1 Original line number Diff line number Diff line Loading @@ -208,7 +208,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'select', '#title' => $this->t('Default time zone'), '#default_value' => $default_timezone, '#options' => TimeZoneFormHelper::getOptionsList(FALSE, TRUE), '#options' => TimeZoneFormHelper::getOptionsListByRegion(), '#weight' => 5, '#attributes' => ['class' => ['timezone-detect']], '#access' => empty($install_state['config_install_path']), Loading
core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php +1 −1 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) { '#type' => 'select', '#title' => $this->t('Time zone override'), '#description' => $this->t('The time zone selected here will always be used'), '#options' => TimeZoneFormHelper::getOptionsList(TRUE, TRUE), '#options' => TimeZoneFormHelper::getOptionsListByRegion(TRUE), '#default_value' => $this->getSetting('timezone_override'), ]; Loading
core/modules/system/src/Form/RegionalForm.php +1 −1 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $system_date = $this->config('system.date'); // Date settings: $zones = TimeZoneFormHelper::getOptionsList(FALSE, TRUE); $zones = TimeZoneFormHelper::getOptionsListByRegion(); $form['locale'] = [ '#type' => 'details', Loading