diff --git a/core/includes/common.inc b/core/includes/common.inc index d6f8945..dae7643 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -1911,20 +1911,15 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL $langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode; } - switch ($type) { - case 'custom': - // No change to format. - break; - default: - // Retrieve the format of the custom $type passed. - if ($type != 'medium') { - $format = config('system.date_time')->get('format.' . $type); - } - // Fall back to 'medium'. - if (empty($format)) { - $format = config('system.date_time')->get('format.medium'); - } - break; + if ($type != 'custom') { + // Retrieve the format of the custom $type passed. + $config = config('system.date'); + $format = $config->get('format.' . $type); + + // Fall back to 'medium'. + if (empty($format)) { + $format = $config->get('format.medium'); + } } // Create a DateTime object from the timestamp. diff --git a/core/includes/form.inc b/core/includes/form.inc index f7d6014..a1f9a1b 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -2948,7 +2948,7 @@ function form_process_date($element) { $element['#tree'] = TRUE; // Determine the order of day, month, year in the site's chosen date format. - $format = config('system.date_time')->get('format.short'); + $format = config('system.date')->get('format.short'); $sort = array(); $sort['day'] = max(strpos($format, 'd'), strpos($format, 'j')); $sort['month'] = max(strpos($format, 'm'), strpos($format, 'M')); diff --git a/core/modules/system/config/system.date.yml b/core/modules/system/config/system.date.yml new file mode 100644 index 0000000..b99b94c --- /dev/null +++ b/core/modules/system/config/system.date.yml @@ -0,0 +1,11 @@ +format: + long: 'l, F j, Y - H:i' + medium: 'D, m/d/Y - H:i' + short: 'm/d/Y - H:i' + html_datetime: 'Y-m-d\TH:i:sO' + html_date: 'Y-m-d' + html_time: 'H:i:s' + html_yearless_date: 'm-d' + html_week: 'Y-\WW' + html_month: 'Y-m' + html_year: 'Y' diff --git a/core/modules/system/config/system.date_time.yml b/core/modules/system/config/system.date_time.yml deleted file mode 100644 index b99b94c..0000000 --- a/core/modules/system/config/system.date_time.yml +++ /dev/null @@ -1,11 +0,0 @@ -format: - long: 'l, F j, Y - H:i' - medium: 'D, m/d/Y - H:i' - short: 'm/d/Y - H:i' - html_datetime: 'Y-m-d\TH:i:sO' - html_date: 'Y-m-d' - html_time: 'H:i:s' - html_yearless_date: 'm-d' - html_week: 'Y-\WW' - html_month: 'Y-m' - html_year: 'Y' diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php index 0effd15..54a96c0 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php @@ -37,7 +37,7 @@ class FormatDateTest extends WebTestBase { function setUp() { parent::setUp(); variable_set('configurable_timezones', 1); - $config = config('system.date_time') + $config = config('system.date') ->set('format.long', 'l, j. F Y - G:i') ->set('format.medium', 'j. F Y - G:i') ->set('format.short', 'Y M j - g:ia') diff --git a/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php b/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php index b9c4baa..9568192 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php @@ -46,7 +46,7 @@ class DateTimeTest extends WebTestBase { // Setup date/time settings for Honolulu time. variable_set('date_default_timezone', 'Pacific/Honolulu'); variable_set('configurable_timezones', 0); - config('system.date_time') + config('system.date') ->set('format.medium', 'Y-m-d H:i:s O') ->save(); diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 4506db2..abd1e40 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -2041,11 +2041,11 @@ function system_regional_settings() { * @ingroup forms * @see system_date_time_settings_submit() */ -function system_date_time_settings($form, $form_state) { +function system_date_time_settings($form, &$form_state) { // Get list of all available date types. drupal_static_reset('system_get_date_types'); $format_types = system_get_date_types(); - $config = config('system.date_time'); + $config = config('system.date'); // Get list of all available date formats. $all_formats = array(); @@ -2112,10 +2112,10 @@ function system_date_time_settings($form, $form_state) { } /** - * Form submission handler for system_date_time_settings(). - */ -function system_date_time_settings_submit($form, $form_state) { - $config = config('system.date_time'); + * Form submission handler for system_date_time_settings(). + */ +function system_date_time_settings_submit($form, &$form_state) { + $config = config('system.date'); foreach ($form_state['values'] as $key => $value) { $pos = strpos($key, 'date_format_'); if ($pos !== FALSE) { @@ -2244,7 +2244,7 @@ function system_add_date_format_type_form_submit($form, &$form_state) { $format_type['locked'] = 0; $format_type['is_new'] = 1; system_date_format_type_save($format_type); - config('system.date_time') + config('system.date') ->set('format.' . $machine_name, $form_state['values']['date_format']) ->save(); drupal_set_message(t('New date type added successfully.')); @@ -3285,7 +3285,7 @@ function system_date_format_localize_form($form, &$form_state, $langcode) { $default = $locale_formats[$type]; } else { - $default = config('system.date_time')->get('format.' . $type); + $default = config('system.date')->get('format.' . $type); } // Show date format select list. diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 1e824e2..19d49eb 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -3520,7 +3520,7 @@ function hook_archiver_info_alter(&$info) { * * To define a date type in a module and make sure a format has been assigned to * it, without requiring a user to visit the administrative interface, use - * @code config('system.date_time')->set('format.' . $type, $format); @endcode + * @code config('system.date')->set('format.' . $type, $format); @endcode * where $type is the machine-readable name defined here, and $format is a PHP * date format string. * @@ -3590,7 +3590,7 @@ function hook_date_format_types_alter(&$types) { * initialization chooses a locale-specific format for the three core-provided * types (see system_get_localized_date_format() for details). If your module * needs to ensure that a date type it defines has a format associated with it, - * call @code config('system.date_time')->set('format.' . $type, $format); @endcode + * call @code config('system.date')->set('format.' . $type, $format); @endcode * where $type is the machine-readable name defined in hook_date_format_types(), * and $format is a PHP date format string. * diff --git a/core/modules/system/system.install b/core/modules/system/system.install index d66024d..780e329 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -2076,7 +2076,7 @@ function system_update_8018() { $variables['date_format_' . $type] = 'format.' . $type; } - update_variables_to_config('system.date_time', $variables); + update_variables_to_config('system.date', $variables); } /** diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 5478b40..45a9c38 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -2088,7 +2088,7 @@ function system_init() { foreach ($formats as $format_type => $format) { $pos = strpos($format_type, 'date_format_'); $format_type = substr($format_type, 12); - $conf['system.date_time']['format'][$format_type] = $format; + $conf['system.date']['format'][$format_type] = $format; } } @@ -2138,7 +2138,7 @@ function system_init() { */ function system_get_localized_date_format($languages) { $formats = array(); - $config = config('system.date_time'); + $config = config('system.date'); // Get list of different format types. $format_types = system_get_date_types(); @@ -3691,7 +3691,7 @@ function system_time_zones($blank = NULL) { // reasons and should not be used, the list is filtered by a regular // expression. if (preg_match('!^((Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)/|UTC$)!', $zone)) { - $zones[$zone] = t('@zone: @date', array('@zone' => t(str_replace('_', ' ', $zone)), '@date' => format_date(REQUEST_TIME, 'custom', config('system.date_time')->get('format.long') . ' O', $zone))); + $zones[$zone] = t('@zone: @date', array('@zone' => t(str_replace('_', ' ', $zone)), '@date' => format_date(REQUEST_TIME, 'custom', config('system.date')->get('format.long') . ' O', $zone))); } } // Sort the translated time zones alphabetically. diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php index de3ab04..bcdb574 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php @@ -28,7 +28,7 @@ class UserTimeZoneTest extends WebTestBase { // Setup date/time settings for Los Angeles time. variable_set('date_default_timezone', 'America/Los_Angeles'); variable_set('configurable_timezones', 1); - config('system.date_time') + config('system.date') ->set('format.medium', 'Y-m-d H:i T') ->save();