diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index e7da6ec..2fa3568 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -2209,13 +2209,15 @@ function drupal_bootstrap($phase = NULL, $new_phase = TRUE) {
*/
function drupal_get_user_timezone() {
global $user;
- if (variable_get('configurable_timezones', 1) && $user->uid && $user->timezone) {
+ $config = config('system.date');
+ if ($config->get('timezone.user.configurable') && $user->uid && $user->timezone) {
return $user->timezone;
}
else {
// Ignore PHP strict notice if time zone has not yet been set in the php.ini
// configuration.
- return variable_get('date_default_timezone', @date_default_timezone_get());
+ $config_data_default_timezone = $config->get('timezone.default');
+ return isset($config_data_default_timezone) ? $config_data_default_timezone : @date_default_timezone_get();
}
}
diff --git a/core/includes/common.inc b/core/includes/common.inc
index d21b9ce..7ee7f90 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -1918,58 +1918,14 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
$langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode;
}
- switch ($type) {
- case 'short':
- $format = variable_get('date_format_short', 'm/d/Y - H:i');
- break;
-
- case 'long':
- $format = variable_get('date_format_long', 'l, F j, Y - H:i');
- break;
-
- case 'html_datetime':
- $format = variable_get('date_format_html_datetime', 'Y-m-d\TH:i:sO');
- break;
-
- case 'html_date':
- $format = variable_get('date_format_html_date', 'Y-m-d');
- break;
-
- case 'html_time':
- $format = variable_get('date_format_html_time', 'H:i:s');
- break;
-
- case 'html_yearless_date':
- $format = variable_get('date_format_html_yearless_date', 'm-d');
- break;
-
- case 'html_week':
- $format = variable_get('date_format_html_week', 'Y-\WW');
- break;
-
- case 'html_month':
- $format = variable_get('date_format_html_month', 'Y-m');
- break;
-
- case 'html_year':
- $format = variable_get('date_format_html_year', 'Y');
- break;
-
- case 'custom':
- // No change to format.
- break;
-
- case 'medium':
- default:
- // Retrieve the format of the custom $type passed.
- if ($type != 'medium') {
- $format = variable_get('date_format_' . $type, '');
- }
- // Fall back to 'medium'.
- if ($format === '') {
- $format = variable_get('date_format_medium', 'D, m/d/Y - H:i');
- }
- break;
+ // Handle the base case: $type == 'custom'
+ // if $type is custom use the format that is provided by the $format argument
+ if ($type != 'custom') {
+ $format = config('system.date')->get('format.' . $type);
+ if (!isset($format)) {
+ // If that type didn't exist return format medium's value
+ $format = config('system.date')->get('format.medium');
+ }
}
// Create a DateTime object from the timestamp.
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 29bce00..d0b824d 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -2953,7 +2953,7 @@ function form_process_date($element) {
$element['#tree'] = TRUE;
// Determine the order of day, month, year in the site's chosen date format.
- $format = variable_get('date_format_short', 'm/d/Y - H:i');
+ $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/includes/install.core.inc b/core/includes/install.core.inc
index 4a37bc2..a0394a6 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -1896,7 +1896,7 @@ function _install_configure_form($form, &$form_state, &$install_state) {
'#type' => 'select',
'#title' => st('Default country'),
'#empty_value' => '',
- '#default_value' => variable_get('site_default_country', NULL),
+ '#default_value' => config('system.date')->get('country.default'),
'#options' => $countries,
'#description' => st('Select the default country for the site.'),
'#weight' => 0,
@@ -1962,8 +1962,10 @@ function install_configure_form_submit($form, &$form_state) {
->set('mail', $form_state['values']['site_mail'])
->save();
- variable_set('date_default_timezone', $form_state['values']['date_default_timezone']);
- variable_set('site_default_country', $form_state['values']['site_default_country']);
+ config('system.date')
+ ->set('timezone.default', $form_state['values']['date_default_timezone'])
+ ->set('country.default', $form_state['values']['site_default_country'])
+ ->save();
// Enable update.module if this option was selected.
if ($form_state['values']['update_status_module'][1]) {
diff --git a/core/modules/aggregator/aggregator.pages.inc b/core/modules/aggregator/aggregator.pages.inc
index 78ca5bc..f45d775 100644
--- a/core/modules/aggregator/aggregator.pages.inc
+++ b/core/modules/aggregator/aggregator.pages.inc
@@ -335,7 +335,7 @@ function template_preprocess_aggregator_item(&$variables) {
$variables['source_date'] = t('%ago ago', array('%ago' => format_interval(REQUEST_TIME - $item->timestamp)));
}
else {
- $variables['source_date'] = format_date($item->timestamp, 'custom', variable_get('date_format_medium', 'D, m/d/Y - H:i'));
+ $variables['source_date'] = format_date($item->timestamp, 'custom', config('system.date')->get('format.medium'));
}
$variables['categories'] = array();
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index 39febca..1c077bb 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -491,7 +491,7 @@ function locale_library_info_alter(&$libraries, $module) {
'ui' => array(
'datepicker' => array(
'isRTL' => $language_interface->direction == LANGUAGE_RTL,
- 'firstDay' => variable_get('date_first_day', 0),
+ 'firstDay' => config('system.date')->get('first_day'),
),
),
),
diff --git a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php
index d556309..0e29aab 100644
--- a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php
+++ b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php
@@ -41,8 +41,11 @@ class OpenIDRegistrationTest extends OpenIDTestBase {
*/
function testRegisterUserWithEmailVerification() {
config('user.settings')->set('verify_mail', TRUE)->save();
- variable_get('configurable_timezones', 1);
- variable_set('date_default_timezone', 'Europe/Brussels');
+
+ config('system.date')
+ ->set('timezone.user.configurable', 1)
+ ->set('timezone.default', 'Europe/Brussels')
+ ->save();
// Tell openid_test.module to respond with these SREG fields.
variable_set('openid_test_response', array(
@@ -98,8 +101,11 @@ class OpenIDRegistrationTest extends OpenIDTestBase {
*/
function testRegisterUserWithoutEmailVerification() {
config('user.settings')->set('verify_mail', FALSE)->save();
- variable_get('configurable_timezones', 1);
- variable_set('date_default_timezone', 'Europe/Brussels');
+
+ config('system.date')
+ ->set('timezone.user.configurable', 1)
+ ->set('timezone.default', 'Europe/Brussels')
+ ->save();
// Tell openid_test.module to respond with these SREG fields.
variable_set('openid_test_response', array(
@@ -139,8 +145,10 @@ class OpenIDRegistrationTest extends OpenIDTestBase {
* information (a username that is already taken, and no e-mail address).
*/
function testRegisterUserWithInvalidSreg() {
- variable_get('configurable_timezones', 1);
- variable_set('date_default_timezone', 'Europe/Brussels');
+ config('system.date')
+ ->set('timezone.user.configurable', 1)
+ ->set('timezone.default', 'Europe/Brussels')
+ ->save();
// Tell openid_test.module to respond with these SREG fields.
$web_user = $this->drupalCreateUser(array());
@@ -190,7 +198,6 @@ class OpenIDRegistrationTest extends OpenIDTestBase {
* information (i.e. no username or e-mail address).
*/
function testRegisterUserWithoutSreg() {
- variable_get('configurable_timezones', 1);
// Load the front page to get the user login block.
$this->drupalGet('');
@@ -230,7 +237,9 @@ class OpenIDRegistrationTest extends OpenIDTestBase {
*/
function testRegisterUserWithAXButNoSREG() {
config('user.settings')->set('verify_mail', FALSE)->save();
- variable_set('date_default_timezone', 'Europe/Brussels');
+ config('system.date')
+ ->set('timezone.default', 'Europe/Brussels')
+ ->save();
// Tell openid_test.module to respond with these AX fields.
variable_set('openid_test_response', array(
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index 10501d0..39c7971 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -700,7 +700,7 @@ abstract class WebTestBase extends TestBase {
// Restore necessary variables.
variable_set('install_task', 'done');
config('system.site')->set('mail', 'simpletest@example.com')->save();
- variable_set('date_default_timezone', date_default_timezone_get());
+ config('system.date')->set('timezone.default', date_default_timezone_get())->save();
// Set up English language.
unset($conf['language_default']);
diff --git a/core/modules/system/config/system.date.yml b/core/modules/system/config/system.date.yml
new file mode 100644
index 0000000..c0d42be
--- /dev/null
+++ b/core/modules/system/config/system.date.yml
@@ -0,0 +1,20 @@
+first_day: '0'
+country:
+ default: ''
+timezone:
+ default: ''
+ user:
+ configurable: '1'
+ default: '0'
+ warn: '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'
\ No newline at end of file
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 9639758..5a02988 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php
@@ -35,15 +35,19 @@ class FormatDateTest extends WebTestBase {
}
function setUp() {
- parent::setUp();
- variable_set('configurable_timezones', 1);
- variable_set('date_format_long', 'l, j. F Y - G:i');
- variable_set('date_format_medium', 'j. F Y - G:i');
- variable_set('date_format_short', 'Y M j - g:ia');
+ parent::setUp('language');
+ config('system.date')
+ ->set('timezone.user.configurable', 1)
+ ->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')
+ ->save();
+
variable_set('locale_custom_strings_' . self::LANGCODE, array(
'' => array('Sunday' => 'domingo'),
'Long month name' => array('March' => 'marzo'),
));
+
$this->refreshVariables();
}
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 6494a4a..f3121e2 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php
@@ -44,9 +44,11 @@ class DateTimeTest extends WebTestBase {
*/
function testTimeZoneHandling() {
// Setup date/time settings for Honolulu time.
- variable_set('date_default_timezone', 'Pacific/Honolulu');
- variable_set('configurable_timezones', 0);
- variable_set('date_format_medium', 'Y-m-d H:i:s O');
+ $config = config('system.date')
+ ->set('timezone.default', 'Pacific/Honolulu')
+ ->set('timezone.user.configurable', 0)
+ ->set('format.medium', 'Y-m-d H:i:s O')
+ ->save();
// Create some nodes with different authored-on dates.
$date1 = '2007-01-31 21:00:00 -1000';
@@ -61,7 +63,7 @@ class DateTimeTest extends WebTestBase {
$this->assertText('2007-07-31 21:00:00 -1000', t('Date should be identical, with GMT offset of -10 hours.'));
// Set time zone to Los Angeles time.
- variable_set('date_default_timezone', 'America/Los_Angeles');
+ $config->set('timezone.default', 'America/Los_Angeles')->save();
// Confirm date format and time zone.
$this->drupalGet("node/$node1->nid");
diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc
index 2bf4343..1006dea 100644
--- a/core/modules/system/system.admin.inc
+++ b/core/modules/system/system.admin.inc
@@ -1958,11 +1958,12 @@ function system_rss_feeds_settings_submit($form, &$form_state) {
* Form builder; Configure the site regional settings.
*
* @ingroup forms
- * @see system_settings_form()
+ * @see system_config_form()
* @see system_regional_settings_submit()
*/
-function system_regional_settings() {
+function system_regional_settings($form, &$form_state) {
$countries = country_get_list();
+ $config = config('system.date');
// Date settings:
$zones = system_time_zones();
@@ -1976,7 +1977,7 @@ function system_regional_settings() {
'#type' => 'select',
'#title' => t('Default country'),
'#empty_value' => '',
- '#default_value' => variable_get('site_default_country', ''),
+ '#default_value' => $config->get('country.default'),
'#options' => $countries,
'#attributes' => array('class' => array('country-detect')),
);
@@ -1984,7 +1985,7 @@ function system_regional_settings() {
$form['locale']['date_first_day'] = array(
'#type' => 'select',
'#title' => t('First day of week'),
- '#default_value' => variable_get('date_first_day', 0),
+ '#default_value' => $config->get('first_day'),
'#options' => array(0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'), 3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday')),
);
@@ -1993,14 +1994,15 @@ function system_regional_settings() {
'#title' => t('Time zones'),
);
+ $date_default_timezone = $config->get('timezone.default');
$form['timezone']['date_default_timezone'] = array(
'#type' => 'select',
'#title' => t('Default time zone'),
- '#default_value' => variable_get('date_default_timezone', date_default_timezone_get()),
+ '#default_value' => isset($date_default_timezone) ? $date_default_timezone : date_default_timezone_get(),
'#options' => $zones,
);
- $configurable_timezones = variable_get('configurable_timezones', 1);
+ $configurable_timezones = $config->get('timezone.user.configurable');
$form['timezone']['configurable_timezones'] = array(
'#type' => 'checkbox',
'#title' => t('Users may set their own time zone.'),
@@ -2020,14 +2022,14 @@ function system_regional_settings() {
$form['timezone']['configurable_timezones_wrapper']['empty_timezone_message'] = array(
'#type' => 'checkbox',
'#title' => t('Remind users at login if their time zone is not set.'),
- '#default_value' => variable_get('empty_timezone_message', 0),
+ '#default_value' => $config->get('timezone.user.warn'),
'#description' => t('Only applied if users may set their own time zone.')
);
$form['timezone']['configurable_timezones_wrapper']['user_default_timezone'] = array(
'#type' => 'radios',
'#title' => t('Time zone for new users'),
- '#default_value' => variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT),
+ '#default_value' => $config->get('timezone.user.default'),
'#options' => array(
DRUPAL_USER_TIMEZONE_DEFAULT => t('Default time zone.'),
DRUPAL_USER_TIMEZONE_EMPTY => t('Empty time zone.'),
@@ -2036,7 +2038,24 @@ function system_regional_settings() {
'#description' => t('Only applied if users may set their own time zone.')
);
- return system_settings_form($form);
+ return system_config_form($form, $form_state);
+}
+
+/**
+ * Form builder submit handler; Handle submission for regional settings.
+ *
+ * @ingroup forms
+ * @see system_regional_settings()
+ */
+function system_regional_settings_submit($form, &$form_state) {
+ config('system.date')
+ ->set('country.default', $form_state['values']['site_default_country'])
+ ->set('first_day', $form_state['values']['date_first_day'])
+ ->set('timezone.default', $form_state['values']['date_default_timezone'])
+ ->set('timezone.user.configurable', $form_state['values']['configurable_timezones'])
+ ->set('timezone.user.warn', $form_state['values']['empty_timezone_message'])
+ ->set('timezone.user.default', $form_state['values']['user_default_timezone'])
+ ->save();
}
/**
@@ -2080,8 +2099,11 @@ function system_date_time_settings() {
foreach ($formats as $f => $format) {
$choices[$f] = format_date(REQUEST_TIME, 'custom', $f);
}
+
+ // Why do we do this?
reset($formats);
- $default = variable_get('date_format_' . $type, key($formats));
+
+ $default = config('system.date')->get('format.' . $type);
// Get date type info for this date type.
$type_info = system_get_date_types($type);
@@ -2232,7 +2254,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);
- variable_set('date_format_' . $machine_name, $form_state['values']['date_format']);
+ config('system.date')->set('format.' . $machine_name, $form_state['values']['date_format'])->save();
drupal_set_message(t('New date type added successfully.'));
$form_state['redirect'] = 'admin/config/regional/date-time';
@@ -3273,7 +3295,7 @@ function system_date_format_localize_form($form, &$form_state, $langcode) {
$default = $locale_formats[$type];
}
else {
- $default = variable_get('date_format_' . $type, key($formats));
+ $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 efdadb4..d639836 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -3313,7 +3313,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 variable_set('date_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.
*
@@ -3383,7 +3383,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 variable_set('date_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 484b384..49ada92 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -1949,6 +1949,22 @@ function system_update_8019() {
}
/**
+ * Moves site system regional settings from variable to config.
+ *
+ * @ingroup config_upgrade
+ */
+function system_update_8020() {
+ update_variables_to_config('system.date', array(
+ 'site_default_country' => 'country.default',
+ 'date_first_day' => 'first_day',
+ 'date_default_timezone' => 'timezone.default',
+ 'configurable_timezones' => 'timezone.user.configurable',
+ 'empty_timezone_message' => 'timezone.user.warn',
+ 'user_default_timezone' => 'timezone.user.default',
+ ));
+}
+
+/**
* @} End of "defgroup updates-7.x-to-8.x".
* The next series of updates should start at 9000.
*/
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index e5dc768..39bbe1c 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -2267,10 +2267,10 @@ function system_init() {
*/
function system_get_localized_date_format($languages) {
$formats = array();
+ $system_date = config('system.date');
// Get list of different format types.
- $format_types = system_get_date_types();
- $short_default = variable_get('date_format_short', 'm/d/Y - H:i');
+ $format_types = array_keys(config('system.date')->get('format'));
// Loop through each language until we find one with some date formats
// configured.
@@ -2287,7 +2287,7 @@ function system_get_localized_date_format($languages) {
// Otherwise get default variable setting. If this is not set, default
// to the short format.
else {
- $formats['date_format_' . $type] = variable_get('date_format_' . $type, $short_default);
+ $formats['date_format_' . $type] = $system_date->get('format.' . $type);
}
}
@@ -2299,15 +2299,16 @@ function system_get_localized_date_format($languages) {
// No locale specific formats found, so use defaults.
$system_types = array('short', 'medium', 'long');
// Handle system types separately as they have defaults if no variable exists.
- $formats['date_format_short'] = $short_default;
- $formats['date_format_medium'] = variable_get('date_format_medium', 'D, m/d/Y - H:i');
- $formats['date_format_long'] = variable_get('date_format_long', 'l, F j, Y - H:i');
+
+ $formats['date_format_short'] = $system_date->get('format.short');
+ $formats['date_format_medium'] = $system_date->get('format.medium');
+ $formats['date_format_long'] = $system_date->get('format.long');
// For non-system types, get the default setting, otherwise use the short
// format.
foreach ($format_types as $type => $type_info) {
if (!in_array($type, $system_types)) {
- $formats['date_format_' . $type] = variable_get('date_format_' . $type, $short_default);
+ $formats['date_format_' . $type] = config('system.date')->get('format.' . $type);
}
}
@@ -2349,7 +2350,7 @@ function system_custom_theme() {
* Implements hook_form_FORM_ID_alter().
*/
function system_form_user_profile_form_alter(&$form, &$form_state) {
- if (variable_get('configurable_timezones', 1)) {
+ if (config('system.date')->get('timezone.user.configurable')) {
system_user_timezone($form, $form_state);
}
return $form;
@@ -2359,7 +2360,8 @@ function system_form_user_profile_form_alter(&$form, &$form_state) {
* Implements hook_form_FORM_ID_alter().
*/
function system_form_user_register_form_alter(&$form, &$form_state) {
- if (variable_get('configurable_timezones', 1) && variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT) == DRUPAL_USER_TIMEZONE_SELECT) {
+ $config = config('system.date');
+ if ($config->get('timezone.user.configurable') && $config->get('timezone.user.default') == DRUPAL_USER_TIMEZONE_SELECT) {
system_user_timezone($form, $form_state);
return $form;
}
@@ -2369,8 +2371,9 @@ function system_form_user_register_form_alter(&$form, &$form_state) {
* Implements hook_user_presave().
*/
function system_user_presave($account) {
- if (variable_get('configurable_timezones', 1) && empty($account->timezone) && !variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT)) {
- $account->timezone = variable_get('date_default_timezone', '');
+ $config = config('system.date');
+ if ($config->get('timezone.user.configurable') && empty($account->timezone) && !$config->get('timezone.user.default')) {
+ $account->timezone = $config->get('timezone.default');
}
}
@@ -2378,8 +2381,9 @@ function system_user_presave($account) {
* Implements hook_user_login().
*/
function system_user_login(&$edit, $account) {
+ $config = config('system.date');
// If the user has a NULL time zone, notify them to set a time zone.
- if (!$account->timezone && variable_get('configurable_timezones', 1) && variable_get('empty_timezone_message', 0)) {
+ if (!$account->timezone && $config->get('timezone.user.configurable') && $config->get('timezone.user.warn')) {
drupal_set_message(t('Configure your account time zone setting.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
}
}
@@ -2400,7 +2404,7 @@ function system_user_timezone(&$form, &$form_state) {
$form['timezone']['timezone'] = array(
'#type' => 'select',
'#title' => t('Time zone'),
- '#default_value' => isset($account->timezone) ? $account->timezone : ($account->uid == $user->uid ? variable_get('date_default_timezone', '') : ''),
+ '#default_value' => isset($account->timezone) ? $account->timezone : ($account->uid == $user->uid ? config('system.date')->get('timezone.default') : ''),
'#options' => system_time_zones($account->uid != $user->uid),
'#description' => t('Select the desired local time and time zone. Dates and times throughout this site will be displayed using this time zone.'),
);
@@ -3793,7 +3797,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', variable_get('date_format_long', 'l, F j, Y - H:i') . ' 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.
@@ -3959,11 +3963,7 @@ function system_run_automated_cron() {
* elements is returned.
*/
function system_get_date_types($type = NULL) {
- $types = &drupal_static(__FUNCTION__);
-
- if (!isset($types)) {
- $types = _system_date_format_types_build();
- }
+ $types = array_keys(config('system.date')->get('format'));
return $type ? (isset($types[$type]) ? $types[$type] : FALSE) : $types;
}
@@ -4180,6 +4180,7 @@ function _system_date_format_types_build() {
* unsaved in the database.
*/
function _system_date_formats_build() {
+ //initial loading of date formats can be greatly improved by CMI
$date_formats = array();
// First handle hook_date_format_types().
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
index d89192f..06f9a8e 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
@@ -149,17 +149,18 @@ class UserRegistrationTest extends WebTestBase {
}
function testRegistrationDefaultValues() {
- $config = config('user.settings');
// Don't require e-mail verification and allow registration by site visitors
// without administrator approval.
- $config
+ $config_user_settings = config('user.settings')
->set('verify_mail', FALSE)
->set('register', USER_REGISTER_VISITORS)
->save();
// Set the default timezone to Brussels.
- variable_set('configurable_timezones', 1);
- variable_set('date_default_timezone', 'Europe/Brussels');
+ $config_system_date = config('system.date')
+ ->set('timezone.user.configurable', 1)
+ ->set('timezone.default', 'Europe/Brussels')
+ ->save();
// Check that the account information fieldset's options are not displayed
// is a fieldset if there is not more than one fieldset in the form.
@@ -181,8 +182,8 @@ class UserRegistrationTest extends WebTestBase {
$this->assertEqual($new_user->theme, '', t('Correct theme field.'));
$this->assertEqual($new_user->signature, '', t('Correct signature field.'));
$this->assertTrue(($new_user->created > REQUEST_TIME - 20 ), t('Correct creation time.'));
- $this->assertEqual($new_user->status, $config->get('register') == USER_REGISTER_VISITORS ? 1 : 0, t('Correct status field.'));
- $this->assertEqual($new_user->timezone, variable_get('date_default_timezone'), t('Correct time zone field.'));
+ $this->assertEqual($new_user->status, $config_user_settings->get('register') == USER_REGISTER_VISITORS ? 1 : 0, t('Correct status field.'));
+ $this->assertEqual($new_user->timezone, $config_system_date->get('timezone.default'), t('Correct time zone field.'));
$this->assertEqual($new_user->langcode, language_default()->langcode, t('Correct language field.'));
$this->assertEqual($new_user->preferred_langcode, language_default()->langcode, t('Correct preferred language field.'));
$this->assertEqual($new_user->picture, 0, t('Correct picture field.'));
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php
index 3ff4daf..eb5e9b8 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php
@@ -26,9 +26,11 @@ class UserTimeZoneTest extends WebTestBase {
*/
function testUserTimeZone() {
// Setup date/time settings for Los Angeles time.
- variable_set('date_default_timezone', 'America/Los_Angeles');
- variable_set('configurable_timezones', 1);
- variable_set('date_format_medium', 'Y-m-d H:i T');
+ $config = config('system.date')
+ ->set('timezone.user.configurable', 1)
+ ->set('timezone.default', 'America/Los_Angeles')
+ ->set('format.medium', 'Y-m-d H:i T')
+ ->save();
// Create a user account and login.
$web_user = $this->drupalCreateUser();
diff --git a/core/modules/user/user.api.php b/core/modules/user/user.api.php
index 660c06b..1b73878 100644
--- a/core/modules/user/user.api.php
+++ b/core/modules/user/user.api.php
@@ -297,8 +297,9 @@ function hook_user_update($account) {
* The user object on which the operation was just performed.
*/
function hook_user_login(&$edit, $account) {
+ $config = config('system.date');
// If the user has a NULL time zone, notify them to set a time zone.
- if (!$account->timezone && variable_get('configurable_timezones', 1) && variable_get('empty_timezone_message', 0)) {
+ if (!$account->timezone && $config->get('timezone.user.configurable') && $config->get('timezone.user.warn')) {
drupal_set_message(t('Configure your account time zone setting.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
}
}