diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index eac2f97..98f043d 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -2172,13 +2172,16 @@ 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 !empty($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 4c86953..a88f1df 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -1899,7 +1899,7 @@ function format_interval($interval, $granularity = 2, $langcode = NULL) {
  *   A UNIX timestamp to format.
  * @param $type
  *   (optional) The format to use, one of:
- *   - One of the built-in formats: 'short', 'medium', 'long', 'html_datetime',
+ *   - One of the built-in formats: 'system_short', 'system_medium', 'system_long', 'html_datetime',
  *     'html_date', 'html_time', 'html_yearless_date', 'html_week',
  *     'html_month', 'html_year'.
  *   - The name of a date type defined by a module in hook_date_format_types(),
@@ -1922,7 +1922,7 @@ function format_interval($interval, $granularity = 2, $langcode = NULL) {
  * @return
  *   A translated date string in the requested format.
  */
-function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
+function format_date($timestamp, $type = 'system_medium', $format = '', $timezone = NULL, $langcode = NULL) {
   // Use the advanced drupal_static() pattern, since this is called very often.
   static $drupal_static_fast;
   if (!isset($drupal_static_fast)) {
@@ -1943,58 +1943,15 @@ 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;
+  // if we have an incoming custom date format use the provided date format pattern.
+  if ($type != 'custom') {
+    $format = config('system.date')->get('formats.' . $type . '.pattern');
+    // Fall back too system_medium if a value was not found.
+    if (!isset($format)) {
+      $format = config('system.date')->get('formats.system_medium.pattern');
+    }
+    // Use the appropriate server pattern.
+    $format = system_get_date_format_pattern($format);
   }
 
   // Create a DateTime object from the timestamp.
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 6956f04..9a73342 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -2963,7 +2963,8 @@ 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('formats.system_short.pattern');
+  $format = system_get_date_format_pattern($format);
   $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 3968682..3530864 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -1933,7 +1933,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,
@@ -1999,8 +1999,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/includes/menu.inc b/core/includes/menu.inc
index c7fcd92..0f97cf4 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -1254,9 +1254,9 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail =
           }
           $parents = $active_trail;
 
-          $expanded = variable_get('menu_expanded', array());
+          $expanded = state()->get('menu_expanded');
           // Check whether the current menu has any links set to be expanded.
-          if (!$only_active_trail && in_array($menu_name, $expanded)) {
+          if (!$only_active_trail && $expanded && in_array($menu_name, $expanded)) {
             // Collect all the links set to be expanded, and then add all of
             // their children to the list as well.
             do {
@@ -2264,10 +2264,11 @@ function theme_menu_local_tasks(&$variables) {
  *
  * @return
  *   An array of menu machine names, in order of preference. The
- *   'menu_default_active_menus' variable may be used to assert a menu order
- *   different from the order of creation, or to prevent a particular menu from
- *   being used at all in the active trail.
- *   E.g., $conf['menu_default_active_menus'] = array('tools', 'main')
+ *   'system.menu.active_menus_default' config item may be used to assert a menu
+ *   order different from the order of creation, or to prevent a particular menu
+ *   from being used at all in the active trail.
+ *   E.g., $conf['system.menu']['active_menus_default'] = array('tools',
+ *   'main').
  */
 function menu_set_active_menu_names($menu_names = NULL) {
   $active = &drupal_static(__FUNCTION__);
@@ -2276,7 +2277,8 @@ function menu_set_active_menu_names($menu_names = NULL) {
     $active = $menu_names;
   }
   elseif (!isset($active)) {
-    $active = variable_get('menu_default_active_menus', array_keys(menu_list_system_menus()));
+    $config = config('system.menu');
+    $active = $config->get('active_menus_default') ?: array_keys(menu_list_system_menus());
   }
   return $active;
 }
@@ -3275,7 +3277,7 @@ function _menu_clear_page_cache() {
  */
 function _menu_set_expanded_menus() {
   $names = db_query("SELECT menu_name FROM {menu_links} WHERE expanded <> 0 GROUP BY menu_name")->fetchCol();
-  variable_set('menu_expanded', $names);
+  state()->set('menu_expanded', $names);
 }
 
 /**
diff --git a/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php
index e88525e..ac48bc8 100644
--- a/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php
@@ -91,7 +91,7 @@ public function onJson(GetResponseForControllerResultEvent $event) {
     $page_callback_result = $event->getControllerResult();
 
     $response = new JsonResponse();
-    $response->setContent($page_callback_result);
+    $response->setData($page_callback_result);
 
     return $response;
   }
diff --git a/core/modules/action/config/action.settings.yml b/core/modules/action/config/action.settings.yml
new file mode 100644
index 0000000..b1d52fa
--- /dev/null
+++ b/core/modules/action/config/action.settings.yml
@@ -0,0 +1 @@
+recursion_limit: '35'
diff --git a/core/modules/aggregator/aggregator.pages.inc b/core/modules/aggregator/aggregator.pages.inc
index 78ca5bc..aacdbd2 100644
--- a/core/modules/aggregator/aggregator.pages.inc
+++ b/core/modules/aggregator/aggregator.pages.inc
@@ -335,7 +335,8 @@ 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'));
+    $format = config('system.date')->get('formats.system_medium.pattern');
+    $variables['source_date'] = format_date($item->timestamp, 'custom', system_get_date_format_pattern($format));
   }
 
   $variables['categories'] = array();
diff --git a/core/modules/ban/ban.admin.inc b/core/modules/ban/ban.admin.inc
index bccd84e..0ea23fc 100644
--- a/core/modules/ban/ban.admin.inc
+++ b/core/modules/ban/ban.admin.inc
@@ -6,11 +6,14 @@
  */
 
 /**
- * Page callback; Displays banned IP addresses.
+ * Page callback: Displays banned IP addresses.
  *
  * @param string $default_ip
- *   (optional) IP address to be passed on to drupal_get_form() for
- *   use as the default value of the IP address form field.
+ *   (optional) IP address to be passed on to drupal_get_form() for use as the
+ *   default value of the IP address form field.
+ *
+ * @return array
+ *   A render array.
  */
 function ban_admin_page($default_ip = '') {
   $rows = array();
@@ -53,7 +56,6 @@ function ban_admin_page($default_ip = '') {
  *
  * @see ban_ip_form_validate()
  * @see ban_ip_form_submit()
- *
  * @ingroup forms
  */
 function ban_ip_form($form, &$form_state, $default_ip) {
@@ -119,7 +121,7 @@ function ban_ip_delete_form($form, &$form_state, array $ban_ip) {
     '#value' => $ban_ip,
   );
   return confirm_form($form,
-    t('Are you sure you want to delete %ip?', array('%ip' => $ban_ip['ip'])),
+    t('Are you sure you want to unblock %ip?', array('%ip' => $ban_ip['ip'])),
     'admin/config/people/ban',
     NULL,
     t('Delete')
diff --git a/core/modules/ban/ban.module b/core/modules/ban/ban.module
index d886871..12405ba 100644
--- a/core/modules/ban/ban.module
+++ b/core/modules/ban/ban.module
@@ -2,7 +2,7 @@
 
 /**
  * @file
- * Enables banning of IP addresses.
+ * Allows to ban individual IP addresses.
  */
 
 /**
@@ -13,7 +13,7 @@ function ban_help($path, $arg) {
     case 'admin/help#ban':
       $output = '';
       $output .= '<h3>' . t('About') . '</h3>';
-      $output .= '<p>' . t('The Ban module allows administrators to ban visits to their site from given IP addresses.') . '</p>';
+      $output .= '<p>' . t('The Ban module allows administrators to ban visits to their site from individual IP addresses.') . '</p>';
       $output .= '<h3>' . t('Uses') . '</h3>';
       $output .= '<dl>';
       $output .= '<dt>' . t('Banning IP addresses') . '</dt>';
@@ -60,61 +60,6 @@ function ban_menu() {
 }
 
 /**
- * Implements hook_boot().
- */
-function ban_boot() {
-  ban_block_denied(ip_address());
-}
-
-/**
- * Returns whether an IP address is blocked.
- *
- * Blocked IP addresses are stored in the database by default. However, for
- * performance reasons we allow an override in variables.
- *
- * @param string $ip
- *   The IP address to check.
- *
- * @return bool
- *   TRUE if access is denied, FALSE if access is allowed.
- */
-function ban_is_denied($ip) {
-  $denied = FALSE;
-  // Because this function is called on every page request, we first check
-  // for an array of IP addresses in settings.php before querying the
-  // database.
-  $blocked_ips = variable_get('ban_ips');
-  if (isset($blocked_ips) && is_array($blocked_ips)) {
-    $denied = in_array($ip, $blocked_ips);
-  }
-  // If $conf['page_cache_without_database'] = TRUE; is set in settings.php,
-  // then the database is not available yet, so IPs recorded in the database
-  // won't be denied. However, the user asked explicitly not to use the
-  // database, and in this case it's also quite likely that the user relies
-  // on higher performance solutions like a firewall.
-  elseif (class_exists('Drupal\Core\Database\Database', FALSE) && function_exists('db_query')) {
-    $denied = (bool) db_query("SELECT 1 FROM {ban_ip} WHERE ip = :ip", array(':ip' => $ip))->fetchField();
-  }
-  return $denied;
-}
-
-/**
- * Prints a message and exits if access from a given IP address is denied.
- *
- * @param string $ip
- *   The IP address to check.
- */
-function ban_block_denied($ip) {
-  // Check whether the given IP address has been blocked.
-  if (ban_is_denied($ip)) {
-    header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
-    // t() is not yet available.
-    print 'Sorry, ' . check_plain($ip) . ' has been banned.';
-    exit();
-  }
-}
-
-/**
  * Loads a banned IP address record from the database.
  *
  * @param int $iid
diff --git a/core/modules/ban/lib/Drupal/ban/BanBundle.php b/core/modules/ban/lib/Drupal/ban/BanBundle.php
new file mode 100644
index 0000000..563332c
--- /dev/null
+++ b/core/modules/ban/lib/Drupal/ban/BanBundle.php
@@ -0,0 +1,31 @@
+<?php
+
+/**
+ * @file
+ * Definition of Drupal\ban\BanBundle.
+ */
+
+namespace Drupal\ban;
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+
+use Drupal\Core\Database\Database;
+
+/**
+ * Defines the Ban bundle.
+ */
+class BanBundle extends Bundle {
+
+  /**
+   * Overrides Symfony\Component\HttpKernel\Bundle\Bundle::build().
+   */
+  public function build(ContainerBuilder $container) {
+    $container->register('ban.ip_manager', 'Drupal\ban\BanIpManager')
+      ->addArgument(new Reference('database'));
+    $container->register('ban.subscriber', 'Drupal\ban\EventSubscriber\BanSubscriber')
+      ->addArgument(new Reference('ban.ip_manager'))
+      ->addTag('event_subscriber');
+  }
+}
diff --git a/core/modules/ban/lib/Drupal/ban/BanIpManager.php b/core/modules/ban/lib/Drupal/ban/BanIpManager.php
new file mode 100644
index 0000000..8ee2e0d
--- /dev/null
+++ b/core/modules/ban/lib/Drupal/ban/BanIpManager.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * @file
+ * Definition of Drupal\ban\BanIpManager.
+ */
+
+namespace Drupal\ban;
+
+use Drupal\Core\Database\Connection;
+
+/**
+ * Ban IP manager.
+ */
+class BanIpManager {
+
+  /**
+   * The database connection used to check the IP against.
+   *
+   * @var Drupal\Core\Database\Connection
+   */
+  protected $connection;
+
+  /**
+   * Construct the BanSubscriber.
+   *
+   * @param Drupal\Core\Database\Connection $connection
+   *   The database connection which will be used to check the IP against.
+   */
+  public function __construct(Connection $connection) {
+    $this->connection = $connection;
+  }
+
+  /**
+   * Returns whether an IP address is blocked.
+   *
+   * @param string $ip
+   *   The IP address to check.
+   *
+   * @return bool
+   *   TRUE if access is denied, FALSE if access is allowed.
+   */
+  public function isDenied($ip) {
+    $denied = $this->connection
+      ->query('SELECT 1 FROM {ban_ip} WHERE ip = :ip', array(':ip' => $ip))
+      ->fetchField();
+    return (bool) $denied;
+  }
+}
diff --git a/core/modules/ban/lib/Drupal/ban/EventSubscriber/BanSubscriber.php b/core/modules/ban/lib/Drupal/ban/EventSubscriber/BanSubscriber.php
new file mode 100644
index 0000000..7dc141c
--- /dev/null
+++ b/core/modules/ban/lib/Drupal/ban/EventSubscriber/BanSubscriber.php
@@ -0,0 +1,65 @@
+<?php
+
+/**
+ * @file
+ * Definition of Drupal\ban\EventSubscriber\BanSubscriber.
+ */
+
+namespace Drupal\ban\EventSubscriber;
+
+use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\HttpKernel\KernelEvents;
+use Symfony\Component\HttpKernel\Event\GetResponseEvent;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+
+use Drupal\ban\BanIpManager;
+
+/**
+ * Ban subscriber for controller requests.
+ */
+class BanSubscriber implements EventSubscriberInterface {
+
+  /**
+   * The manager used to check the IP against.
+   *
+   * @var Drupal\ban\BanIpManager
+   */
+  protected $manager;
+
+  /**
+   * Construct the BanSubscriber.
+   *
+   * @param Drupal\ban\BanIpManager $manager
+   *   The manager used to check the IP against.
+   */
+  public function __construct(BanIpManager $manager) {
+    $this->manager = $manager;
+  }
+
+  /**
+   * Response with 403 if the visitor's IP adress is banned.
+   *
+   * @param Symfony\Component\HttpKernel\Event\GetResponseEvent $event
+   *   The Event to process.
+   */
+  public function onKernelRequestBannedIpCheck(GetResponseEvent $event) {
+    // @todo convert this to Request::getClientIP().
+    $ip = ip_address();
+    if ($this->manager->isDenied($ip)) {
+      $response = new Response('Sorry, ' . check_plain($ip) . ' has been banned.', 403);
+      $event->setResponse($response);
+    }
+  }
+
+  /**
+   * Registers the methods in this class that should be listeners.
+   *
+   * @return array
+   *   An array of event listener definitions.
+   */
+  static function getSubscribedEvents() {
+    $events[KernelEvents::REQUEST][] = array('onKernelRequestBannedIpCheck', 40);
+    return $events;
+  }
+
+}
diff --git a/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php b/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php
index 9c085bb..584ac00 100644
--- a/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php
+++ b/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php
@@ -197,7 +197,6 @@ public function submitOptionsForm(&$form, &$form_state) {
         break;
       case 'block_caching':
         $this->setOption('block_caching', $form_state['values']['block_caching']);
-        $this->saveBlockCache($form_state['view']->storage->get('name') . '-'. $form_state['display_id'], $form_state['values']['block_caching']);
         break;
     }
   }
@@ -216,7 +215,7 @@ public function usesExposed() {
    * Update the block delta when you change the machine readable name of the display.
    */
   protected function updateBlockBid($name, $old_delta, $delta) {
-    $old_hashes = $hashes = variable_get('views_block_hashes', array());
+    $old_hashes = $hashes = state()->get('views_block_hashes');
 
     $old_delta = $name . '-' . $old_delta;
     $delta = $name . '-' . $delta;
@@ -240,27 +239,7 @@ protected function updateBlockBid($name, $old_delta, $delta) {
 
     // Update the hashes if needed.
     if ($hashes != $old_hashes) {
-      variable_set('views_block_hashes', $hashes);
-    }
-  }
-
-  /**
-   * Save the block cache setting in the blocks table if this block allready
-   * exists in the blocks table. Dirty fix untill http://drupal.org/node/235673 gets in.
-   */
-  protected function saveBlockCache($delta, $cache_setting) {
-    if (strlen($delta) >= 32) {
-      $delta = md5($delta);
-    }
-    if (db_table_exists('block') && $bid = db_query("SELECT bid FROM {block} WHERE module = 'views' AND delta = :delta", array(
-        ':delta' => $delta))->fetchField()) {
-      db_update('block')
-        ->fields(array(
-        'cache' => $cache_setting,
-        ))
-        ->condition('module', 'views')
-        ->condition('delta', $delta)
-        ->execute();
+      state()->set('views_block_hashes', $hashes);
     }
   }
 
diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc
index 26e9c8b..2736e7d 100644
--- a/core/modules/comment/comment.admin.inc
+++ b/core/modules/comment/comment.admin.inc
@@ -128,7 +128,7 @@ function comment_admin_overview($form, &$form_state, $arg) {
           '#href' => 'node/' . $comment->nid,
         ),
       ),
-      'changed' => format_date($comment->changed, 'short'),
+      'changed' => format_date($comment->changed, 'system_short'),
     );
     $links = array();
     $links['edit'] = array(
diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc
index c77cb67..b15d79e 100644
--- a/core/modules/comment/comment.tokens.inc
+++ b/core/modules/comment/comment.tokens.inc
@@ -186,11 +186,11 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
           break;
 
         case 'created':
-          $replacements[$original] = format_date($comment->created, 'medium', '', NULL, $langcode);
+          $replacements[$original] = format_date($comment->created, 'system_medium', '', NULL, $langcode);
           break;
 
         case 'changed':
-          $replacements[$original] = format_date($comment->changed, 'medium', '', NULL, $langcode);
+          $replacements[$original] = format_date($comment->changed, 'system_medium', '', NULL, $langcode);
           break;
 
         case 'node':
diff --git a/core/modules/dblog/dblog.admin.inc b/core/modules/dblog/dblog.admin.inc
index 3b56f45..2f45565 100644
--- a/core/modules/dblog/dblog.admin.inc
+++ b/core/modules/dblog/dblog.admin.inc
@@ -63,7 +63,7 @@ function dblog_overview() {
         // Cells
         array('class' => 'icon'),
         t($dblog->type),
-        format_date($dblog->timestamp, 'short'),
+        format_date($dblog->timestamp, 'system_short'),
         theme('dblog_message', array('event' => $dblog, 'link' => TRUE)),
         theme('username', array('account' => $dblog)),
         filter_xss($dblog->link),
@@ -162,7 +162,7 @@ function dblog_event($id) {
       ),
       array(
         array('data' => t('Date'), 'header' => TRUE),
-        format_date($dblog->timestamp, 'long'),
+        format_date($dblog->timestamp, 'system_long'),
       ),
       array(
         array('data' => t('User'), 'header' => TRUE),
diff --git a/core/modules/field/modules/text/config/text.settings.yml b/core/modules/field/modules/text/config/text.settings.yml
new file mode 100644
index 0000000..1ff3cbc
--- /dev/null
+++ b/core/modules/field/modules/text/config/text.settings.yml
@@ -0,0 +1 @@
+default_summary_length: 600
diff --git a/core/modules/field/modules/text/text.install b/core/modules/field/modules/text/text.install
index a2ef0cf..72d879f 100644
--- a/core/modules/field/modules/text/text.install
+++ b/core/modules/field/modules/text/text.install
@@ -65,3 +65,14 @@ function text_field_schema($field) {
     ),
   );
 }
+
+/**
+ * Moves teaser length from variable to config.
+ *
+ * @ingroup config_upgrade
+ */
+function text_update_8000() {
+  update_variables_to_config('text.settings', array(
+    'teaser_length' => 'default_summary_length',
+  ));
+}
diff --git a/core/modules/field/modules/text/text.module b/core/modules/field/modules/text/text.module
index efb0079..7e92375 100644
--- a/core/modules/field/modules/text/text.module
+++ b/core/modules/field/modules/text/text.module
@@ -229,9 +229,7 @@ function _text_sanitize($instance, $langcode, $item, $column) {
 function text_summary($text, $format = NULL, $size = NULL) {
 
   if (!isset($size)) {
-    // What used to be called 'teaser' is now called 'summary', but
-    // the variable 'teaser_length' is preserved for backwards compatibility.
-    $size = variable_get('teaser_length', 600);
+    $size = config('text.settings')->get('default_summary_length');
   }
 
   // Find where the delimiter is in the body
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php
index 4d56b7b..187c41e 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php
@@ -56,8 +56,8 @@ function testFileTokenReplacement() {
     $tests['[file:mime]'] = check_plain($file->filemime);
     $tests['[file:size]'] = format_size($file->filesize);
     $tests['[file:url]'] = check_plain(file_create_url($file->uri));
-    $tests['[file:timestamp]'] = format_date($file->timestamp, 'medium', '', NULL, $language_interface->langcode);
-    $tests['[file:timestamp:short]'] = format_date($file->timestamp, 'short', '', NULL, $language_interface->langcode);
+    $tests['[file:timestamp]'] = format_date($file->timestamp, 'system_medium', '', NULL, $language_interface->langcode);
+    $tests['[file:timestamp:short]'] = format_date($file->timestamp, 'system_short', '', NULL, $language_interface->langcode);
     $tests['[file:owner]'] = check_plain(user_format_name($this->admin_user));
     $tests['[file:owner:uid]'] = $file->uid;
 
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index 3ebe97d..a7587a7 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -573,7 +573,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/menu/menu.module b/core/modules/menu/menu.module
index 22f5dd7..73e4380 100644
--- a/core/modules/menu/menu.module
+++ b/core/modules/menu/menu.module
@@ -274,11 +274,13 @@ function menu_save($menu) {
     case SAVED_NEW:
       // Make sure the menu is present in the active menus variable so that its
       // items may appear in the menu active trail.
-      // @see menu_set_active_menu_names()
-      $active_menus = variable_get('menu_default_active_menus', array_keys(menu_get_menus()));
+      // See menu_set_active_menu_names().
+      $config = config('system.menu');
+
+      $active_menus = $config->get('active_menus_default') ?: array_keys(menu_get_menus());
       if (!in_array($menu['menu_name'], $active_menus)) {
         $active_menus[] = $menu['menu_name'];
-        variable_set('menu_default_active_menus', $active_menus);
+        $config->set('active_menus_default', $active_menus);
       }
 
       module_invoke_all('menu_insert', $menu);
diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc
index 2ca2d3e..ca80d2c 100644
--- a/core/modules/node/node.admin.inc
+++ b/core/modules/node/node.admin.inc
@@ -539,7 +539,7 @@ function node_admin_nodes() {
       'type' => check_plain(node_get_type_label($node)),
       'author' => theme('username', array('account' => $node)),
       'status' => $node->status ? t('published') : t('not published'),
-      'changed' => format_date($node->changed, 'short'),
+      'changed' => format_date($node->changed, 'system_short'),
     );
     if ($multilingual) {
       $options[$node->nid]['language_name'] = language_name($node->langcode);
diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc
index eef3d42..b5571bb 100644
--- a/core/modules/node/node.pages.inc
+++ b/core/modules/node/node.pages.inc
@@ -269,13 +269,13 @@ function node_revision_overview($node) {
   foreach ($revisions as $revision) {
     $row = array();
     if ($revision->current_vid > 0) {
-      $row[] = array('data' => t('!date by !username', array('!date' => l(format_date($revision->timestamp, 'short'), "node/$node->nid"), '!username' => theme('username', array('account' => $revision))))
+      $row[] = array('data' => t('!date by !username', array('!date' => l(format_date($revision->timestamp, 'system_short'), "node/$node->nid"), '!username' => theme('username', array('account' => $revision))))
                                . (($revision->log != '') ? '<p class="revision-log">' . filter_xss($revision->log) . '</p>' : ''),
                      'class' => array('revision-current'));
       $row[] = array('data' => drupal_placeholder(t('current revision')), 'class' => array('revision-current'));
     }
     else {
-      $row[] = t('!date by !username', array('!date' => l(format_date($revision->timestamp, 'short'), "node/$node->nid/revisions/$revision->vid/view"), '!username' => theme('username', array('account' => $revision))))
+      $row[] = t('!date by !username', array('!date' => l(format_date($revision->timestamp, 'system_short'), "node/$node->nid/revisions/$revision->vid/view"), '!username' => theme('username', array('account' => $revision))))
                . (($revision->log != '') ? '<p class="revision-log">' . filter_xss($revision->log) . '</p>' : '');
       if ($revert_permission) {
         $links['revert'] = array(
diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc
index 0bd1000..09aa1c6 100644
--- a/core/modules/node/node.tokens.inc
+++ b/core/modules/node/node.tokens.inc
@@ -163,11 +163,11 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr
           break;
 
         case 'created':
-          $replacements[$original] = format_date($node->created, 'medium', '', NULL, $langcode);
+          $replacements[$original] = format_date($node->created, 'system_medium', '', NULL, $langcode);
           break;
 
         case 'changed':
-          $replacements[$original] = format_date($node->changed, 'medium', '', NULL, $langcode);
+          $replacements[$original] = format_date($node->changed, 'system_medium', '', NULL, $langcode);
           break;
       }
     }
diff --git a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php
index debb9cd..9822ff9 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 @@ function setUp() {
    */
   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 @@ function testRegisterUserWithEmailVerification() {
    */
   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 @@ function testRegisterUserWithoutEmailVerification() {
    * 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 @@ function testRegisterUserWithInvalidSreg() {
    * 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 @@ function testRegisterUserWithoutSreg() {
    */
   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/search/search.pages.inc b/core/modules/search/search.pages.inc
index b6a1930..9d99063 100644
--- a/core/modules/search/search.pages.inc
+++ b/core/modules/search/search.pages.inc
@@ -122,7 +122,7 @@ function template_preprocess_search_result(&$variables) {
     $info['user'] = $result['user'];
   }
   if (!empty($result['date'])) {
-    $info['date'] = format_date($result['date'], 'short');
+    $info['date'] = format_date($result['date'], 'system_short');
   }
   if (isset($result['extra']) && is_array($result['extra'])) {
     $info = array_merge($info, $result['extra']);
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index f9bc3f4..ebadf43 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -228,7 +228,6 @@ protected function drupalCreateNode(array $settings = array()) {
     $settings += array(
       'body'      => array(LANGUAGE_NOT_SPECIFIED => array(array())),
       'title'     => $this->randomName(8),
-      'comment'   => COMMENT_NODE_OPEN,
       'changed'   => REQUEST_TIME,
       'promote'   => NODE_NOT_PROMOTED,
       'revision'  => 1,
@@ -239,6 +238,13 @@ protected function drupalCreateNode(array $settings = array()) {
       'langcode'  => LANGUAGE_NOT_SPECIFIED,
     );
 
+    // Add in comment settings for nodes.
+    if (module_exists('comment')) {
+      $settings += array(
+        'comment' => COMMENT_NODE_OPEN,
+      );
+    }
+
     // Use the original node's created time for existing nodes.
     if (isset($settings['created']) && !isset($settings['date'])) {
       $settings['date'] = format_date($settings['created'], 'custom', 'Y-m-d H:i:s O');
diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsBlockVisitorsTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsBlockVisitorsTest.php
index 4657d10..82990e3 100644
--- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsBlockVisitorsTest.php
+++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsBlockVisitorsTest.php
@@ -50,7 +50,7 @@ function testIPAddressBlocking() {
 
     // Unblock the IP address.
     $this->clickLink('unban IP address');
-    $this->assertRaw(t('Are you sure you want to delete %ip?', array('%ip' => $test_ip_address)), 'IP address deletion confirmation found.');
+    $this->assertRaw(t('Are you sure you want to unblock %ip?', array('%ip' => $test_ip_address)), 'IP address deletion confirmation found.');
     $edit = array();
     $this->drupalPost('admin/config/people/ban/delete/1', NULL, t('Delete'));
     $this->assertRaw(t('The IP address %ip was deleted.', array('%ip' => $test_ip_address)), 'IP address deleted.');
diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php
index 0b5909d..dd25d52 100644
--- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php
+++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php
@@ -46,7 +46,7 @@ function testStatisticsTokenReplacement() {
     $tests['[node:total-count]'] = 1;
     $tests['[node:day-count]'] = 1;
     $tests['[node:last-view]'] = format_date($statistics['timestamp']);
-    $tests['[node:last-view:short]'] = format_date($statistics['timestamp'], 'short');
+    $tests['[node:last-view:short]'] = format_date($statistics['timestamp'], 'system_short');
 
     // Test to make sure that we generated something for each token.
     $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
diff --git a/core/modules/system/config/system.date.yml b/core/modules/system/config/system.date.yml
new file mode 100644
index 0000000..3565022
--- /dev/null
+++ b/core/modules/system/config/system.date.yml
@@ -0,0 +1,60 @@
+first_day: '0'
+country:
+  default: ''
+timezone:
+  default: ''
+  user:
+    configurable: '1'
+    default: '0'
+    warn: '0'
+formats:
+  system_long:
+    name: 'Default Long Date'
+    pattern:
+      php: 'l, F j, Y - H:i'
+    locked: 0
+  system_medium:
+    name: 'Default Medium Date'
+    pattern:
+      php: 'D, m/d/Y - H:i'
+    locked: 0
+  system_short:
+    name: 'Default Short Date'
+    pattern:
+      php: 'm/d/Y - H:i'
+    locked: 0
+  html_datetime:
+    name: 'HTML Datetime'
+    pattern:
+      php: 'Y-m-d\TH:i:sO'
+    locked: 1
+  html_date:
+    name: 'HTML Date'
+    pattern:
+      php: 'Y-m-d'
+    locked: 1
+  html_time:
+    name: 'HTML Time'
+    pattern:
+      php: 'H:i:s'
+    locked: 1
+  html_yearless_date:
+    name: 'HTML Yearless date'
+    pattern:
+      php: 'm-d'
+    locked: 1
+  html_week:
+    name: 'HTML Week'
+    pattern:
+      php: 'Y-\WW'
+    locked: 1
+  html_month:
+    name: 'HTML Month'
+    pattern:
+      php: 'Y-m'
+    locked: 1
+  html_year:
+    name: 'HTML Year'
+    pattern:
+     php: 'Y'
+    locked: 1
diff --git a/core/modules/system/config/system.menu.yml b/core/modules/system/config/system.menu.yml
new file mode 100644
index 0000000..e73636c
--- /dev/null
+++ b/core/modules/system/config/system.menu.yml
@@ -0,0 +1 @@
+active_menus_default: []
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 d3cd9e6..5b73eac 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 @@ public static function getInfo() {
   }
 
   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('formats.system_long.pattern.php', 'l, j. F Y - G:i')
+      ->set('formats.system_medium.pattern.php', 'j. F Y - G:i')
+      ->set('formats.system_short.pattern.php', '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();
   }
 
@@ -57,20 +61,16 @@ function testAdminDefinedFormatDate() {
 
     // Add new date format.
     $admin_date_format = 'j M y';
-    $edit = array('date_format' => $admin_date_format);
-    $this->drupalPost('admin/config/regional/date-time/formats/add', $edit, 'Add format');
-
-    // Add new date type.
     $edit = array(
-      'date_type' => 'Example Style',
-      'machine_name' => 'example_style',
-      'date_format' => $admin_date_format,
+      'date_format_id' => 'example_style',
+      'date_format_name' => 'Example Style',
+      'date_format_pattern' => $admin_date_format,
     );
-    $this->drupalPost('admin/config/regional/date-time/types/add', $edit, 'Add date type');
+    $this->drupalPost('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
 
     $timestamp = strtotime('2007-03-10T00:00:00+00:00');
     $this->assertIdentical(format_date($timestamp, 'example_style', '', 'America/Los_Angeles'), '9 Mar 07', 'Test format_date() using an admin-defined date type.');
-    $this->assertIdentical(format_date($timestamp, 'undefined_style'), format_date($timestamp, 'medium'), 'Test format_date() defaulting to medium when $type not found.');
+    $this->assertIdentical(format_date($timestamp, 'undefined_style'), format_date($timestamp, 'system_medium'), 'Test format_date() defaulting to medium when $type not found.');
   }
 
   /**
@@ -123,9 +123,9 @@ function testFormatDate() {
     $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test a different language.');
     $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London'), 'Monday, 26-Mar-07 01:00:00 BST', 'Test a different time zone.');
     $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T'), 'domingo, 25-Mar-07 17:00:00 PDT', 'Test custom date format.');
-    $this->assertIdentical(format_date($timestamp, 'long'), 'domingo, 25. marzo 2007 - 17:00', 'Test long date format.');
-    $this->assertIdentical(format_date($timestamp, 'medium'), '25. marzo 2007 - 17:00', 'Test medium date format.');
-    $this->assertIdentical(format_date($timestamp, 'short'), '2007 Mar 25 - 5:00pm', 'Test short date format.');
+    $this->assertIdentical(format_date($timestamp, 'system_long'), 'domingo, 25. marzo 2007 - 17:00', 'Test long date format.');
+    $this->assertIdentical(format_date($timestamp, 'system_medium'), '25. marzo 2007 - 17:00', 'Test medium date format.');
+    $this->assertIdentical(format_date($timestamp, 'system_short'), '2007 Mar 25 - 5:00pm', 'Test short date format.');
     $this->assertIdentical(format_date($timestamp), '25. marzo 2007 - 17:00', 'Test default date format.');
     // Test HTML time element formats.
     $this->assertIdentical(format_date($timestamp, 'html_datetime'), '2007-03-25T17:00:00-0700', 'Test html_datetime date format.');
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php b/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php
index 10f49b9..172973d 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php
@@ -19,7 +19,7 @@ class DateFormatsLanguageTest extends WebTestBase {
    *
    * @var array
    */
-  public static $modules = array('node', 'language');
+  public static $modules = array('node', 'locale');
 
   public static function getInfo() {
     return array(
@@ -57,20 +57,39 @@ function testLocalizeDateFormats() {
     );
     $this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
 
+    // Add new date format for French.
+    $edit = array(
+      'date_format_id' => 'example_style_fr',
+      'date_format_name' => 'Example Style',
+      'date_format_pattern' => 'd.m.Y - H:i',
+      'date_langcode[]' => array('fr'),
+    );
+    $this->drupalPost('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
+
+    // Add new date format for English.
+    $edit = array(
+      'date_format_id' => 'example_style_en',
+      'date_format_name' => 'Example Style',
+      'date_format_pattern' => 'j M Y - g:ia',
+      'date_langcode[]' => array('en'),
+    );
+    $this->drupalPost('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
+
     // Configure date formats.
     $this->drupalGet('admin/config/regional/date-time/locale');
     $this->assertText('French', 'Configured languages appear.');
     $edit = array(
-      'date_format_long' => 'd.m.Y - H:i',
-      'date_format_medium' => 'd.m.Y - H:i',
-      'date_format_short' => 'd.m.Y - H:i',
+      'date_format_system_long' => 'example_style_fr',
+      'date_format_system_medium' => 'example_style_fr',
+      'date_format_system_short' => 'example_style_fr',
     );
     $this->drupalPost('admin/config/regional/date-time/locale/fr/edit', $edit, t('Save configuration'));
     $this->assertText(t('Configuration saved.'), 'French date formats updated.');
+
     $edit = array(
-      'date_format_long' => 'j M Y - g:ia',
-      'date_format_medium' => 'j M Y - g:ia',
-      'date_format_short' => 'j M Y - g:ia',
+      'date_format_system_long' => 'example_style_en',
+      'date_format_system_medium' => 'example_style_en',
+      'date_format_system_short' => 'example_style_en',
     );
     $this->drupalPost('admin/config/regional/date-time/locale/en/edit', $edit, t('Save configuration'));
     $this->assertText(t('Configuration saved.'), 'English date formats updated.');
@@ -85,5 +104,10 @@ function testLocalizeDateFormats() {
     $this->drupalGet('fr/node/' . $node->nid);
     $french_date = format_date($node->created, 'custom', 'd.m.Y');
     $this->assertText($french_date, 'French date format appears');
+
+    // Make sure we can reset dates back to default.
+    $this->drupalPost('admin/config/regional/date-time/locale/en/reset', array(), t('Reset'));
+    $this->drupalGet('node/' . $node->nid);
+    $this->assertNoText($english_date, 'English date format does not appear');
   }
 }
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 8483da2..53dccbe 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php
@@ -38,15 +38,16 @@ function setUp() {
     $this->drupalLogin($this->admin_user);
   }
 
-
   /**
    * Test time zones and DST handling.
    */
   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('formats.system_medium.pattern.php', '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 +62,7 @@ function testTimeZoneHandling() {
     $this->assertText('2007-07-31 21:00:00 -1000', '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");
@@ -71,64 +72,33 @@ function testTimeZoneHandling() {
   }
 
   /**
-   * Test date type configuration.
-   */
-  function testDateTypeConfiguration() {
-    // Confirm system date types appear.
-    $this->drupalGet('admin/config/regional/date-time');
-    $this->assertText(t('Medium'), 'System date types appear in date type list.');
-    $this->assertNoRaw('href="/admin/config/regional/date-time/types/medium/delete"', 'No delete link appear for system date types.');
-
-    // Add custom date type.
-    $this->clickLink(t('Add date type'));
-    $date_type = strtolower($this->randomName(8));
-    $machine_name = 'machine_' . $date_type;
-    $date_format = 'd.m.Y - H:i';
-    $edit = array(
-      'date_type' => $date_type,
-      'machine_name' => $machine_name,
-      'date_format' => $date_format,
-    );
-    $this->drupalPost('admin/config/regional/date-time/types/add', $edit, t('Add date type'));
-    $this->assertEqual($this->getUrl(), url('admin/config/regional/date-time', array('absolute' => TRUE)), 'Correct page redirection.');
-    $this->assertText(t('New date type added successfully.'), 'Date type added confirmation message appears.');
-    $this->assertText($date_type, 'Custom date type appears in the date type list.');
-    $this->assertText(t('delete'), 'Delete link for custom date type appears.');
-
-    // Delete custom date type.
-    $this->clickLink(t('delete'));
-    $this->drupalPost('admin/config/regional/date-time/types/' . $machine_name . '/delete', array(), t('Remove'));
-    $this->assertEqual($this->getUrl(), url('admin/config/regional/date-time', array('absolute' => TRUE)), 'Correct page redirection.');
-    $this->assertText(t('Removed date type ' . $date_type), 'Custom date type removed.');
-  }
-
-  /**
    * Test date format configuration.
    */
   function testDateFormatConfiguration() {
     // Confirm 'no custom date formats available' message appears.
     $this->drupalGet('admin/config/regional/date-time/formats');
-    $this->assertText(t('No custom date formats available.'), 'No custom date formats message appears.');
 
     // Add custom date format.
     $this->clickLink(t('Add format'));
+    $date_format_id = strtolower($this->randomName(8));
+    $name = ucwords($date_format_id);
+    $date_format = 'd.m.Y - H:i';
     $edit = array(
-      'date_format' => 'Y',
+      'date_format_id' => $date_format_id,
+      'date_format_name' => $name,
+      'date_format_pattern' => $date_format,
     );
     $this->drupalPost('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
     $this->assertEqual($this->getUrl(), url('admin/config/regional/date-time/formats', array('absolute' => TRUE)), 'Correct page redirection.');
-    $this->assertNoText(t('No custom date formats available.'), 'No custom date formats message does not appear.');
-    $this->assertText(t('Custom date format added.'), 'Custom date format added.');
-
-    // Ensure custom date format appears in date type configuration options.
-    $this->drupalGet('admin/config/regional/date-time');
-    $this->assertRaw('<option value="Y">', 'Custom date format appears in options.');
+    $this->assertText(t('Custom date format updated.'), 'Date format added confirmation message appears.');
+    $this->assertText($date_format_id, 'Custom date format appears in the date format list.');
+    $this->assertText(t('delete'), 'Delete link for custom date format appears.');
 
     // Edit custom date format.
     $this->drupalGet('admin/config/regional/date-time/formats');
     $this->clickLink(t('edit'));
     $edit = array(
-      'date_format' => 'Y m',
+      'date_format_pattern' => 'Y m',
     );
     $this->drupalPost($this->getUrl(), $edit, t('Save format'));
     $this->assertEqual($this->getUrl(), url('admin/config/regional/date-time/formats', array('absolute' => TRUE)), 'Correct page redirection.');
@@ -136,80 +106,37 @@ function testDateFormatConfiguration() {
 
     // Delete custom date format.
     $this->clickLink(t('delete'));
-    $this->drupalPost($this->getUrl(), array(), t('Remove'));
+    $this->drupalPost('admin/config/regional/date-time/formats/' . $date_format_id . '/delete', array(), t('Remove'));
     $this->assertEqual($this->getUrl(), url('admin/config/regional/date-time/formats', array('absolute' => TRUE)), 'Correct page redirection.');
-    $this->assertText(t('Removed date format'), 'Custom date format removed successfully.');
+    $this->assertText(t('Removed date format ' . $name), 'Custom date format removed.');
+
+    // Make sure the date does not exist in config.
+    $date_format = config('system.date')->get('formats.' . $date_format_id);
+    $this->assertIdentical($date_format, NULL);
   }
 
   /**
    * Test if the date formats are stored properly.
    */
   function testDateFormatStorage() {
-    $date_format = array(
-      'type' => 'short',
-      'format' => 'dmYHis',
-      'locked' => 0,
-      'is_new' => 1,
+    $date_format_info = array(
+      'name' => 'testDateFormatStorage Short Format',
+      'pattern' => array('php' => 'dmYHis'),
     );
-    system_date_format_save($date_format);
-
-    $format = db_select('date_formats', 'df')
-      ->fields('df', array('format'))
-      ->condition('type', 'short')
-      ->condition('format', 'dmYHis')
-      ->execute()
-      ->fetchField();
-    $this->verbose($format);
-    $this->assertEqual('dmYHis', $format, 'Unlocalized date format resides in general table.');
-
-    $format = db_select('date_format_locale', 'dfl')
-      ->fields('dfl', array('format'))
-      ->condition('type', 'short')
-      ->condition('format', 'dmYHis')
-      ->execute()
-      ->fetchField();
-    $this->assertFalse($format, 'Unlocalized date format resides not in localized table.');
-
-    // Enable German language
-    $language = new Language(array(
-      'langcode' => 'de',
-      'default' => TRUE,
-    ));
-    language_save($language);
-
-    $date_format = array(
-      'type' => 'short',
-      'format' => 'YMDHis',
-      'locales' => array('de', 'tr'),
-      'locked' => 0,
-      'is_new' => 1,
-    );
-    system_date_format_save($date_format);
-
-    $format = db_select('date_format_locale', 'dfl')
-      ->fields('dfl', array('format'))
-      ->condition('type', 'short')
-      ->condition('format', 'YMDHis')
-      ->condition('language', 'de')
-      ->execute()
-      ->fetchField();
-    $this->assertEqual('YMDHis', $format, 'Localized date format resides in localized table.');
-
-    $format = db_select('date_formats', 'df')
-      ->fields('df', array('format'))
-      ->condition('type', 'short')
-      ->condition('format', 'YMDHis')
-      ->execute()
-      ->fetchField();
-    $this->assertEqual('YMDHis', $format, 'Localized date format resides in general table too.');
-
-    $format = db_select('date_format_locale', 'dfl')
-      ->fields('dfl', array('format'))
-      ->condition('type', 'short')
-      ->condition('format', 'YMDHis')
-      ->condition('language', 'tr')
-      ->execute()
-      ->fetchColumn();
-    $this->assertFalse($format, 'Localized date format for disabled language is ignored.');
+
+    system_date_format_save('test_short', $date_format_info);
+
+    $format = config('system.date')->get('formats.test_short.pattern.php');
+    $this->assertEqual('dmYHis', $format, 'Unlocalized date format resides in general config.');
+
+    $date_format_info['locales'] = array('en');
+
+    system_date_format_save('test_short_en', $date_format_info);
+
+    $format = config('system.date')->get('formats.test_short_en.pattern.php');
+    $this->assertEqual('dmYHis', $format, 'Localized date format resides in general config too.');
+
+    $format = config('locale.config.en.system.date')->get('formats.test_short_en.pattern.php');
+    $this->assertEqual('dmYHis', $format, 'Localized date format resides in localized config.');
   }
 }
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php
index 3859041..1c367fb 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php
@@ -44,7 +44,7 @@ function testTokenReplacement() {
     $target .= check_plain($account->name);
     $target .= format_interval(REQUEST_TIME - $node->created, 2, $language_interface->langcode);
     $target .= check_plain($user->name);
-    $target .= format_date(REQUEST_TIME, 'short', '', NULL, $language_interface->langcode);
+    $target .= format_date(REQUEST_TIME, 'system_short', '', NULL, $language_interface->langcode);
 
     // Test that the clear parameter cleans out non-existent tokens.
     $result = token_replace($source, array('node' => $node), array('langcode' => $language_interface->langcode, 'clear' => TRUE));
@@ -154,9 +154,9 @@ function testSystemDateTokenReplacement() {
 
     // Generate and test tokens.
     $tests = array();
-    $tests['[date:short]'] = format_date($date, 'short', '', NULL, $language_interface->langcode);
-    $tests['[date:medium]'] = format_date($date, 'medium', '', NULL, $language_interface->langcode);
-    $tests['[date:long]'] = format_date($date, 'long', '', NULL, $language_interface->langcode);
+    $tests['[date:short]'] = format_date($date, 'system_short', '', NULL, $language_interface->langcode);
+    $tests['[date:medium]'] = format_date($date, 'system_medium', '', NULL, $language_interface->langcode);
+    $tests['[date:long]'] = format_date($date, 'system_long', '', NULL, $language_interface->langcode);
     $tests['[date:custom:m/j/Y]'] = format_date($date, 'custom', 'm/j/Y', NULL, $language_interface->langcode);
     $tests['[date:since]'] = format_interval((REQUEST_TIME - $date), 2, $language_interface->langcode);
     $tests['[date:raw]'] = filter_xss($date);
diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc
index c55289c..4096665 100644
--- a/core/modules/system/system.admin.inc
+++ b/core/modules/system/system.admin.inc
@@ -1852,11 +1852,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();
+  $system_date = config('system.date');
 
   // Date settings:
   $zones = system_time_zones();
@@ -1870,7 +1871,7 @@ function system_regional_settings() {
     '#type' => 'select',
     '#title' => t('Default country'),
     '#empty_value' => '',
-    '#default_value' => variable_get('site_default_country', ''),
+    '#default_value' => $system_date->get('country.default'),
     '#options' => $countries,
     '#attributes' => array('class' => array('country-detect')),
   );
@@ -1878,7 +1879,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' => $system_date->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')),
   );
 
@@ -1887,14 +1888,15 @@ function system_regional_settings() {
     '#title' => t('Time zones'),
   );
 
+  $date_default_timezone = $system_date->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 = $system_date->get('timezone.user.configurable');
   $form['timezone']['configurable_timezones'] = array(
     '#type' => 'checkbox',
     '#title' => t('Users may set their own time zone.'),
@@ -1914,14 +1916,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' => $system_date->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' => $system_date->get('timezone.user.default'),
     '#options' => array(
       DRUPAL_USER_TIMEZONE_DEFAULT => t('Default time zone.'),
       DRUPAL_USER_TIMEZONE_EMPTY   => t('Empty time zone.'),
@@ -1930,7 +1932,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();
 }
 
 /**
@@ -1940,76 +1959,33 @@ function system_regional_settings() {
  * @see system_settings_form()
  */
 function system_date_time_settings() {
-  // Get list of all available date types.
-  drupal_static_reset('system_get_date_types');
-  $format_types = system_get_date_types();
-
-  // Get list of all available date formats.
-  $all_formats = array();
-  drupal_static_reset('system_get_date_formats');
-  $date_formats = system_get_date_formats(); // Call this to rebuild the list, and to have default list.
-  foreach ($date_formats as $type => $format_info) {
-    $all_formats = array_merge($all_formats, $format_info);
-  }
-  $custom_formats = system_get_date_formats('custom');
-  if (!empty($format_types)) {
-    foreach ($format_types as $type => $type_info) {
-      // If a system type, only show the available formats for that type and
-      // custom ones.
-      if ($type_info['locked'] == 1) {
-        $formats = system_get_date_formats($type);
-        if (empty($formats)) {
-          $formats = $all_formats;
-        }
-        elseif (!empty($custom_formats)) {
-          $formats = array_merge($formats, $custom_formats);
-        }
-      }
-      // If a user configured type, show all available date formats.
-      else {
-        $formats = $all_formats;
-      }
+  // Display any user-defined date formats.
+  $date_formats = system_get_date_formats();
 
-      $choices = array();
-      foreach ($formats as $f => $format) {
-        $choices[$f] = format_date(REQUEST_TIME, 'custom', $f);
-      }
-      reset($formats);
-      $default = variable_get('date_format_' . $type, key($formats));
-
-      // Get date type info for this date type.
-      $type_info = system_get_date_types($type);
-      $form['formats']['#theme'] = 'system_date_time_settings';
-
-      // Show date format select list.
-      $form['formats']['format']['date_format_' . $type] = array(
-        '#type' => 'select',
-        '#title' => check_plain($type_info['title']),
-        '#attributes' => array('class' => array('date-format')),
-        '#default_value' => (isset($choices[$default]) ? $default : 'custom'),
-        '#options' => $choices,
-      );
+  $header = array(
+    'machine_name' => array('data' => t('Machine name')),
+    'name' => array('data' => t('Name')),
+    'pattern' => array('data' => t('Date format')),
+    'example' => array('data' => t('Example of use')),
+  );
 
-      $links = array();
-      // If this isn't a system provided type, allow the user to remove it from
-      // the system.
-      if ($type_info['locked'] == 0) {
-        $links['delete'] = array(
-          'title' => t('delete'),
-          'href' => "admin/config/regional/date-time/types/$type/delete",
-        );
-      }
-      $form['formats']['operations']["date_format_$type"] = array(
-        '#type' => 'operations',
-        '#links' => $links,
-      );
-    }
+  $rows = array();
+  foreach ($date_formats as $date_format_id => $format_info) {
+    $pattern = system_get_date_format_pattern($format_info['pattern']);
+    $rows[] = array(
+      $date_format_id,
+      $format_info['name'],
+      $pattern,
+      format_date(REQUEST_TIME, 'custom', $pattern),
+    );
   }
 
-  // Display a message if no date types configured.
-  $form['#empty_text'] = t('No date types available. <a href="@link">Add date type</a>.', array('@link' => url('admin/config/regional/date-time/types/add')));
+  $variables = array(
+    'header' => $header,
+    'rows' => $rows,
+  );
 
-  return system_settings_form($form);
+  return theme('table', $variables);
 }
 
 /**
@@ -2044,97 +2020,6 @@ function theme_system_date_time_settings($variables) {
   return $output;
 }
 
-
-/**
- * Add new date type.
- *
- * @ingroup forms
- * @ingroup system_add_date_format_type_form_validate()
- * @ingroup system_add_date_format_type_form_submit()
- */
-function system_add_date_format_type_form($form, &$form_state) {
-  $form['date_type'] = array(
-    '#title' => t('Date type'),
-    '#type' => 'textfield',
-    '#required' => TRUE,
-  );
-  $form['machine_name'] = array(
-    '#type' => 'machine_name',
-    '#machine_name' => array(
-      'exists' => 'system_get_date_types',
-      'source' => array('date_type'),
-    ),
-  );
-
-  // Get list of all available date formats.
-  $formats = array();
-  drupal_static_reset('system_get_date_formats');
-  $date_formats = system_get_date_formats(); // Call this to rebuild the list, and to have default list.
-  foreach ($date_formats as $type => $format_info) {
-    $formats = array_merge($formats, $format_info);
-  }
-  $custom_formats = system_get_date_formats('custom');
-  if (!empty($custom_formats)) {
-    $formats = array_merge($formats, $custom_formats);
-  }
-  $choices = array();
-  foreach ($formats as $f => $format) {
-    $choices[$f] = format_date(REQUEST_TIME, 'custom', $f);
-  }
-  // Show date format select list.
-  $form['date_format'] = array(
-    '#type' => 'select',
-    '#title' => t('Date format'),
-    '#attributes' => array('class' => array('date-format')),
-    '#options' => $choices,
-    '#required' => TRUE,
-  );
-
-  $form['actions'] = array('#type' => 'actions');
-  $form['actions']['submit'] = array(
-    '#type' => 'submit',
-    '#value' => t('Add date type'),
-  );
-
-  $form['#validate'][] = 'system_add_date_format_type_form_validate';
-  $form['#submit'][] = 'system_add_date_format_type_form_submit';
-
-  return $form;
-}
-
-/**
- * Validate system_add_date_format_type form submissions.
- */
-function system_add_date_format_type_form_validate($form, &$form_state) {
-  if (!empty($form_state['values']['machine_name']) && !empty($form_state['values']['date_type'])) {
-    if (!preg_match("/^[a-zA-Z0-9_]+$/", trim($form_state['values']['machine_name']))) {
-      form_set_error('machine_name', t('The date type must contain only alphanumeric characters and underscores.'));
-    }
-    $types = system_get_date_types();
-    if (in_array(trim($form_state['values']['machine_name']), array_keys($types))) {
-      form_set_error('machine_name', t('This date type already exists. Enter a unique type.'));
-    }
-  }
-}
-
-/**
- * Process system_add_date_format_type form submissions.
- */
-function system_add_date_format_type_form_submit($form, &$form_state) {
-  $machine_name = trim($form_state['values']['machine_name']);
-
-  $format_type = array();
-  $format_type['title'] = trim($form_state['values']['date_type']);
-  $format_type['type'] = $machine_name;
-  $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']);
-
-  drupal_set_message(t('New date type added successfully.'));
-  $form_state['redirect'] = 'admin/config/regional/date-time';
-}
-
 /**
  * Return the date for a given format string via Ajax.
  */
@@ -2659,16 +2544,19 @@ function theme_system_themes_page($variables) {
 
 /**
  * Menu callback; present a form for deleting a date format.
+ *
+ * @param string $date_format_id
+ *   The machine name for the date format that may be deleted
  */
-function system_date_delete_format_form($form, &$form_state, $dfid) {
-  $form['dfid'] = array(
+function system_date_delete_format_form($form, &$form_state, $date_format_id) {
+  $form['date_format_id'] = array(
     '#type' => 'value',
-    '#value' => $dfid,
+    '#value' => $date_format_id,
   );
-  $format = system_get_date_format($dfid);
-
+  $format = system_get_date_formats($date_format_id);
+  $pattern = system_get_date_format_pattern($format['pattern']);
   $output = confirm_form($form,
-    t('Are you sure you want to remove the format %format?', array('%format' => format_date(REQUEST_TIME, 'custom', $format->format))),
+    t('Are you sure you want to remove the format %name : %format?', array('%name' => $format['name'], '%format' => format_date(REQUEST_TIME, 'custom', $pattern))),
     'admin/config/regional/date-time/formats',
     t('This action cannot be undone.'),
     t('Remove'), t('Cancel'),
@@ -2683,76 +2571,53 @@ function system_date_delete_format_form($form, &$form_state, $dfid) {
  */
 function system_date_delete_format_form_submit($form, &$form_state) {
   if ($form_state['values']['confirm']) {
-    $format = system_get_date_format($form_state['values']['dfid']);
-    system_date_format_delete($form_state['values']['dfid']);
-    drupal_set_message(t('Removed date format %format.', array('%format' => format_date(REQUEST_TIME, 'custom', $format->format))));
+    $format = system_get_date_formats($form_state['values']['date_format_id']);
+    system_date_format_delete($form_state['values']['date_format_id']);
+    drupal_set_message(t('Removed date format %format.', array('%format' => $format['name'])));
     $form_state['redirect'] = 'admin/config/regional/date-time/formats';
   }
 }
 
 /**
- * Menu callback; present a form for deleting a date type.
- */
-function system_delete_date_format_type_form($form, &$form_state, $format_type) {
-  $form['format_type'] = array(
-    '#type' => 'value',
-    '#value' => $format_type,
-  );
-  $type_info = system_get_date_types($format_type);
-
-  $output = confirm_form($form,
-    t('Are you sure you want to remove the date type %type?', array('%type' => $type_info['title'])),
-    'admin/config/regional/date-time',
-    t('This action cannot be undone.'),
-    t('Remove'), t('Cancel'),
-    'confirm'
-  );
-
-  return $output;
-}
-
-/**
- * Delete a configured date type.
- */
-function system_delete_date_format_type_form_submit($form, &$form_state) {
-  if ($form_state['values']['confirm']) {
-    $type_info = system_get_date_types($form_state['values']['format_type']);
-    system_date_format_type_delete($form_state['values']['format_type']);
-    drupal_set_message(t('Removed date type %type.', array('%type' => $type_info['title'])));
-    $form_state['redirect'] = 'admin/config/regional/date-time';
-  }
-}
-
-
-/**
  * Displays the date format strings overview page.
  */
 function system_date_time_formats() {
-  $header = array(t('Format'), t('Operations'));
+  $header = array(
+    array('data' => t('Machine Name'), 'field' => 'machine_name'),
+    array('data' => t('Name'), 'field' => 'name'),
+    array('data' => t('Pattern'), 'field' => 'pattern'),
+    array('data' => t('Operations'))
+  );
   $rows = array();
 
-  drupal_static_reset('system_get_date_formats');
-  $formats = system_get_date_formats('custom');
+  $formats = system_get_date_formats();
+
   if (!empty($formats)) {
-    foreach ($formats as $format) {
-      $row = array();
-      $row[] = array('data' => format_date(REQUEST_TIME, 'custom', $format['format']));
-      $links = array();
-      $links['edit'] = array(
-        'title' => t('edit'),
-        'href' => 'admin/config/regional/date-time/formats/' . $format['dfid'] . '/edit',
-      );
-      $links['delete'] = array(
-        'title' => t('delete'),
-        'href' => 'admin/config/regional/date-time/formats/' . $format['dfid'] . '/delete',
-      );
-      $row[] = array(
-        'data' => array(
+    foreach ($formats as $date_format_id => $format_info) {
+      // Do not display date formats that are locked
+      if (empty($format_info['locked'])) {
+        $row = array();
+        $row[] = array('data' => $date_format_id);
+        $row[] = array('data' => $format_info['name']);
+        $row[] = array('data' => format_date(REQUEST_TIME, 'custom', system_get_date_format_pattern($format_info['pattern'])));
+
+        // Prepare Operational links
+        $links = array();
+        $links['edit'] = array(
+          'title' => t('edit'),
+          'href' => 'admin/config/regional/date-time/formats/' . $date_format_id . '/edit',
+        );
+        $links['delete'] = array(
+          'title' => t('delete'),
+          'href' => 'admin/config/regional/date-time/formats/' . $date_format_id . '/delete',
+        );
+        $row['operations'] = array('data' => array(
           '#type' => 'operations',
           '#links' => $links,
-        ),
-      );
-      $rows[] = $row;
+        ));
+
+        $rows[] = $row;
+      }
     }
   }
 
@@ -2768,13 +2633,17 @@ function system_date_time_formats() {
 
 /**
  * Allow users to add additional date formats.
+ *
+ * @param string $date_format_id (optional)
+ *   When present, provides the machine name of the date format that is being
+ *   modified.
  */
-function system_configure_date_formats_form($form, &$form_state, $dfid = 0) {
+function system_configure_date_formats_form($form, &$form_state, $date_format_id = '') {
   $js_settings = array(
     'type' => 'setting',
     'data' => array(
       'dateTime' => array(
-        'date-format' => array(
+        'date-format-pattern' => array(
           'text' => t('Displayed as'),
           'lookup' => url('admin/config/regional/date-time/formats/lookup'),
         ),
@@ -2782,22 +2651,42 @@ function system_configure_date_formats_form($form, &$form_state, $dfid = 0) {
     ),
   );
 
-  if ($dfid) {
-    $form['dfid'] = array(
+  if (empty($date_format_id)) {
+    $form['date_format_id'] = array(
+      '#type' => 'machine_name',
+      '#title' => t('Machine-readable name'),
+      '#description' => t('A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.'),
+      '#machine_name' => array(
+        'exists' => 'system_date_format_exists',
+        'source' => array('machine_name'),
+      ),
+    );
+    $now = '';
+  }
+  else {
+    $form['date_format_id'] = array(
       '#type' => 'value',
-      '#value' => $dfid,
+      '#value' => $date_format_id,
     );
-    $format = system_get_date_format($dfid);
+    $format_info = system_get_date_formats($date_format_id);
+    $pattern = system_get_date_format_pattern($format_info['pattern']);
+    $now = t('Displayed as %date', array('%date' => format_date(REQUEST_TIME, 'custom', $pattern)));
   }
 
-  $now = ($dfid ? t('Displayed as %date', array('%date' => format_date(REQUEST_TIME, 'custom', $format->format))) : '');
+  $form['date_format_name'] = array(
+    '#type' => 'textfield',
+    '#title' => 'Name',
+    '#maxlength' => 100,
+    '#description' => t('Name of the date format'),
+    '#default_value' => empty($format_info['name']) ? '' : $format_info['name']
+  );
 
-  $form['date_format'] = array(
+  $form['date_format_pattern'] = array(
     '#type' => 'textfield',
     '#title' => t('Format string'),
     '#maxlength' => 100,
     '#description' => t('A user-defined date format. See the <a href="@url">PHP manual</a> for available options.', array('@url' => 'http://php.net/manual/function.date.php')),
-    '#default_value' => ($dfid ? $format->format : ''),
+    '#default_value' => empty($pattern) ? '' : $pattern,
     '#field_suffix' => ' <small id="edit-date-format-suffix">' . $now . '</small>',
     '#attached' => array(
       'library' => array(array('system', 'drupal.system')),
@@ -2806,10 +2695,27 @@ function system_configure_date_formats_form($form, &$form_state, $dfid = 0) {
     '#required' => TRUE,
   );
 
+  $languages = language_list();
+
+  $options = array();
+  foreach ($languages as $langcode => $data) {
+    $options[$langcode] = $data->name;
+  }
+
+  if (!empty($options)) {
+    $form['date_langcode'] = array(
+      '#title' => t('Select localizations'),
+      '#type' => 'select',
+      '#options' => $options,
+      '#multiple' => TRUE,
+      '#default_value' => empty($format_info['locales']) ? '' : $format_info['locales']
+    );
+  }
+
   $form['actions'] = array('#type' => 'actions');
   $form['actions']['update'] = array(
     '#type' => 'submit',
-    '#value' => ($dfid ? t('Save format') : t('Add format')),
+    '#value' => (!empty($date_format_id) ? t('Save format') : t('Add format')),
   );
 
   $form['#validate'][] = 'system_add_date_formats_form_validate';
@@ -2819,12 +2725,25 @@ function system_configure_date_formats_form($form, &$form_state, $dfid = 0) {
 }
 
 /**
+ * Check if the chosen machine_name exists or not
+ */
+function system_date_format_exists($candidate_machine_name) {
+  if ($formats = system_get_date_formats()) {
+    return array_key_exists($candidate_machine_name, $formats);
+  }
+  return FALSE;
+}
+
+/**
  * Validate new date format string submission.
  */
 function system_add_date_formats_form_validate($form, &$form_state) {
-  $formats = system_get_date_formats('custom');
-  $format = trim($form_state['values']['date_format']);
-  if (!empty($formats) && in_array($format, array_keys($formats)) && (!isset($form_state['values']['dfid']) || $form_state['values']['dfid'] != $formats[$format]['dfid'])) {
+  $formats = system_get_date_formats();
+  $format = trim($form_state['values']['date_format_pattern']);
+
+  // The machine name field should already check to see if the requested machine name is available
+  // Regardless of machine_name or human readable name, check to see if the provided pattern exists
+  if (!empty($formats) && in_array($format, array_values($formats)) && (!isset($form_state['values']['date_format_id']) || $form_state['values']['date_format_id'] != $formats[$format]['date_format_id'])) {
     form_set_error('date_format', t('This format already exists. Enter a unique format string.'));
   }
 }
@@ -2833,17 +2752,19 @@ function system_add_date_formats_form_validate($form, &$form_state) {
  * Process new date format string submission.
  */
 function system_add_date_formats_form_submit($form, &$form_state) {
+  $pattern_type = system_get_date_format_pattern_type();
   $format = array();
-  $format['format'] = trim($form_state['values']['date_format']);
-  $format['type'] = 'custom';
+  $format['name'] = check_plain($form_state['values']['date_format_name']);
+  $format['pattern'][$pattern_type] = trim($form_state['values']['date_format_pattern']);
+  $format['locales'] = !empty($form_state['values']['date_langcode']) ? $form_state['values']['date_langcode'] : array();
+  // Formats created in the UI are not locked.
   $format['locked'] = 0;
-  if (!empty($form_state['values']['dfid'])) {
-    system_date_format_save($format, $form_state['values']['dfid']);
+
+  system_date_format_save($form_state['values']['date_format_id'], $format);
+  if (!empty($form_state['values']['date_format_id'])) {
     drupal_set_message(t('Custom date format updated.'));
   }
   else {
-    $format['is_new'] = 1;
-    system_date_format_save($format);
     drupal_set_message(t('Custom date format added.'));
   }
 
@@ -2906,36 +2827,39 @@ function system_date_format_localize_form($form, &$form_state, $langcode) {
     '#value' => $langcode,
   );
 
-  // Get list of date format types.
-  $types = system_get_date_types();
-
   // Get list of available formats.
   $formats = system_get_date_formats();
+
   $choices = array();
-  foreach ($formats as $type => $list) {
-    foreach ($list as $f => $format) {
-      $choices[$f] = format_date(REQUEST_TIME, 'custom', $f);
+  foreach ($formats as $date_format_id => $format_info) {
+    $pattern = system_get_date_format_pattern($format_info['pattern']);
+    // Ignore values that are localized.
+    if (empty($format_info['locales'])) {
+      $choices[$date_format_id] = format_date(REQUEST_TIME, 'custom', $pattern);
+    }
+    else {
+      unset($formats[$date_format_id]);
     }
   }
-  reset($formats);
 
   // Get configured formats for each language.
   $locale_formats = system_date_format_locale($langcode);
-  // Display a form field for each format type.
-  foreach ($types as $type => $type_info) {
-    if (!empty($locale_formats) && in_array($type, array_keys($locale_formats))) {
-      $default = $locale_formats[$type];
-    }
-    else {
-      $default = variable_get('date_format_' . $type, key($formats));
+  if (!empty($locale_formats)) {
+    $formats += $locale_formats;
+    foreach ($locale_formats as $date_format_id => $format_info) {
+      $pattern = system_get_date_format_pattern($format_info['pattern']);
+      $choices[$date_format_id] = format_date(REQUEST_TIME, 'custom', $pattern);
     }
+  }
 
+  // Display a form field for each format type.
+  foreach ($formats as $date_format_id => $format_info) {
     // Show date format select list.
-    $form['date_formats']['date_format_' . $type] = array(
+    $form['date_formats']['date_format_' . $date_format_id] = array(
       '#type' => 'select',
-      '#title' => check_plain($type_info['title']),
+      '#title' => check_plain($format_info['name']),
       '#attributes' => array('class' => array('date-format')),
-      '#default_value' => (isset($choices[$default]) ? $default : 'custom'),
+      '#default_value' => isset($choices[$date_format_id]) ? $date_format_id : 'custom',
       '#options' => $choices,
     );
   }
@@ -2955,14 +2879,12 @@ function system_date_format_localize_form($form, &$form_state, $langcode) {
 function system_date_format_localize_form_submit($form, &$form_state) {
   $langcode = $form_state['values']['langcode'];
 
-  // Get list of date format types.
-  $types = system_get_date_types();
-  foreach ($types as $type => $type_info) {
-    $format = $form_state['values']['date_format_' . $type];
-    if ($format == 'custom') {
-      $format = $form_state['values']['date_format_' . $type . '_custom'];
+  $formats = system_get_date_formats();
+  foreach ($formats as $date_format_id => $format_info) {
+    if (isset($form_state['values']['date_format_' . $date_format_id])) {
+      $format = $form_state['values']['date_format_' . $date_format_id];
+      system_date_format_localize_form_save($langcode, $date_format_id, $formats[$format]['pattern']);
     }
-    system_date_format_localize_form_save($langcode, $type, $format);
   }
   drupal_set_message(t('Configuration saved.'));
   $form_state['redirect'] = 'admin/config/regional/date-time/locale';
@@ -2980,8 +2902,8 @@ function system_date_format_localize_form_submit($form, &$form_state) {
 function theme_system_date_format_localize_form($variables) {
   $form = $variables['form'];
   $header = array(
-    t('Date type'),
-    t('Format'),
+    'machine_name' => t('Machine Name'),
+    'pattern' => t('Format'),
   );
 
   foreach (element_children($form['date_formats']) as $key) {
@@ -3022,9 +2944,8 @@ function system_date_format_localize_reset_form($form, &$form_state, $langcode)
  * Form submission handler for locale_date_format_reset_form().
  */
 function system_date_format_localize_reset_form_submit($form, &$form_state) {
-  db_delete('date_format_locale')
-    ->condition('language', $form_state['values']['langcode'])
-    ->execute();
+  config('locale.config.' . $form['langcode']['#value'] . '.system.date')
+    ->delete();
   $form_state['redirect'] = 'admin/config/regional/date-time/locale';
 }
 
@@ -3034,23 +2955,13 @@ function system_date_format_localize_reset_form_submit($form, &$form_state) {
  * @param $langcode
  *   Language code, can be 2 characters, e.g. 'en' or 5 characters, e.g.
  *   'en-CA'.
- * @param $type
- *   Date format type, e.g. 'short', 'medium'.
+ * @param $date_format_id
+ *   Date format id, e.g. 'short', 'medium'.
  * @param $format
  *   The date format string.
  */
-function system_date_format_localize_form_save($langcode, $type, $format) {
-  $locale_format = array();
-  $locale_format['language'] = $langcode;
-  $locale_format['type'] = $type;
-  $locale_format['format'] = $format;
-
-  $is_existing = (bool) db_query_range('SELECT 1 FROM {date_format_locale} WHERE language = :langcode AND type = :type', 0, 1, array(':langcode' => $langcode, ':type' => $type))->fetchField();
-  if ($is_existing) {
-    $keys = array('type', 'language');
-    drupal_write_record('date_format_locale', $locale_format, $keys);
-  }
-  else {
-    drupal_write_record('date_format_locale', $locale_format);
-  }
+function system_date_format_localize_form_save($langcode, $date_format_id, $format) {
+  config('locale.config.' . $langcode . '.system.date')
+    ->set('formats.' . $date_format_id . '.pattern', $format)
+    ->save();
 }
diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php
index 2d09534..9db4b3a 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -3322,143 +3322,6 @@ function hook_archiver_info_alter(&$info) {
 }
 
 /**
- * Define additional date types.
- *
- * Next to the 'long', 'medium' and 'short' date types defined in core, any
- * module can define additional types that can be used when displaying dates,
- * by implementing this hook. A date type is basically just a name for a date
- * format.
- *
- * Date types are used in the administration interface: a user can assign
- * date format types defined in hook_date_formats() to date types defined in
- * this hook. Once a format has been assigned by a user, the machine name of a
- * type can be used in the format_date() function to format a date using the
- * chosen formatting.
- *
- * 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
- * where $type is the machine-readable name defined here, and $format is a PHP
- * date format string.
- *
- * To avoid namespace collisions with date types defined by other modules, it is
- * recommended that each date type starts with the module name. A date type
- * can consist of letters, numbers and underscores.
- *
- * @return
- *   An array of date types where the keys are the machine-readable names and
- *   the values are the human-readable labels.
- *
- * @see hook_date_formats()
- * @see format_date()
- */
-function hook_date_format_types() {
-  // Define the core date format types.
-  return array(
-    'long' => t('Long'),
-    'medium' => t('Medium'),
-    'short' => t('Short'),
-  );
-}
-
-/**
- * Modify existing date types.
- *
- * Allows other modules to modify existing date types like 'long'. Called by
- * _system_date_format_types_build(). For instance, A module may use this hook
- * to apply settings across all date types, such as locking all date types so
- * they appear to be provided by the system.
- *
- * @param $types
- *   A list of date types. Each date type is keyed by the machine-readable name
- *   and the values are associative arrays containing:
- *   - is_new: Set to FALSE to override previous settings.
- *   - module: The name of the module that created the date type.
- *   - type: The machine-readable date type name.
- *   - title: The human-readable date type name.
- *   - locked: Specifies that the date type is system-provided.
- */
-function hook_date_format_types_alter(&$types) {
-  foreach ($types as $name => $type) {
-    $types[$name]['locked'] = 1;
-  }
-}
-
-/**
- * Define additional date formats.
- *
- * This hook is used to define the PHP date format strings that can be assigned
- * to date types in the administrative interface. A module can provide date
- * format strings for the core-provided date types ('long', 'medium', and
- * 'short'), or for date types defined in hook_date_format_types() by itself
- * or another module.
- *
- * Since date formats can be locale-specific, you can specify the locales that
- * each date format string applies to. There may be more than one locale for a
- * format. There may also be more than one format for the same locale. For
- * example d/m/Y and Y/m/d work equally well in some locales. You may wish to
- * define some additional date formats that aren't specific to any one locale,
- * for example, "Y m". For these cases, the 'locales' component of the return
- * value should be omitted.
- *
- * Providing a date format here does not normally assign the format to be
- * used with the associated date type -- a user has to choose a format for each
- * date type in the administrative interface. There is one exception: locale
- * 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
- * where $type is the machine-readable name defined in hook_date_format_types(),
- * and $format is a PHP date format string.
- *
- * @return
- *   A list of date formats to offer as choices in the administrative
- *   interface. Each date format is a keyed array consisting of three elements:
- *   - 'type': The date type name that this format can be used with, as
- *     declared in an implementation of hook_date_format_types().
- *   - 'format': A PHP date format string to use when formatting dates. It
- *     can contain any of the formatting options described at
- *     http://php.net/manual/function.date.php
- *   - 'locales': (optional) An array of 2 and 5 character locale codes,
- *     defining which locales this format applies to (for example, 'en',
- *     'en-us', etc.). If your date format is not language-specific, leave this
- *     array empty.
- *
- * @see hook_date_format_types()
- */
-function hook_date_formats() {
-  return array(
-    array(
-      'type' => 'mymodule_extra_long',
-      'format' => 'l jS F Y H:i:s e',
-      'locales' => array('en-ie'),
-    ),
-    array(
-      'type' => 'mymodule_extra_long',
-      'format' => 'l jS F Y h:i:sa',
-      'locales' => array('en', 'en-us'),
-    ),
-    array(
-      'type' => 'short',
-      'format' => 'F Y',
-      'locales' => array(),
-    ),
-  );
-}
-
-/**
- * Alter date formats declared by another module.
- *
- * Called by _system_date_format_types_build() to allow modules to alter the
- * return values from implementations of hook_date_formats().
- */
-function hook_date_formats_alter(&$formats) {
-  foreach ($formats as $id => $format) {
-    $formats[$id]['locales'][] = 'en-ca';
-  }
-}
-
-/**
  * Alters theme operation links.
  *
  * @param $theme_groups
@@ -3607,7 +3470,7 @@ function hook_tokens($type, $tokens, array $data = array(), array $options = arr
           break;
 
         case 'created':
-          $replacements[$original] = format_date($node->created, 'medium', '', NULL, $langcode);
+          $replacements[$original] = format_date($node->created, 'system_medium', '', NULL, $langcode);
           break;
       }
     }
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index 1f191ac..06c3265 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -2203,6 +2203,33 @@ function system_update_8032() {
 }
 
 /**
+ * Converts active_menus_default variable to config.
+ *
+ * @ingroup config_upgrade
+ */
+function system_update_8033() {
+  update_variables_to_config('system.menu', array(
+    'active_menus_default' => 'active_menus_default'
+  ));
+}
+
+/**
+ * Moves site system regional settings from variable to config.
+ *
+ * @ingroup config_upgrade
+ */
+function system_update_8034() {
+  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 4475104..d215c6c 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -857,48 +857,10 @@ function system_menu() {
     'file' => 'system.admin.inc',
   );
   $items['admin/config/regional/date-time'] = array(
-    'title' => 'Date and time',
-    'description' => 'Configure display formats for date and time.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('system_date_time_settings'),
-    'access arguments' => array('administer site configuration'),
-    'weight' => -15,
-    'file' => 'system.admin.inc',
-  );
-  $items['admin/config/regional/date-time/types'] = array(
-    'title' => 'Types',
-    'description' => 'Configure display formats for date and time.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('system_date_time_settings'),
-    'access arguments' => array('administer site configuration'),
-    'type' => MENU_DEFAULT_LOCAL_TASK,
-    'weight' => -10,
-    'file' => 'system.admin.inc',
-  );
-  $items['admin/config/regional/date-time/types/add'] = array(
-    'title' => 'Add date type',
-    'description' => 'Add new date type.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('system_add_date_format_type_form'),
-    'access arguments' => array('administer site configuration'),
-    'type' => MENU_LOCAL_ACTION,
-    'weight' => -10,
-    'file' => 'system.admin.inc',
-  );
-  $items['admin/config/regional/date-time/types/%/delete'] = array(
-    'title' => 'Delete date type',
-    'description' => 'Allow users to delete a configured date type.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('system_delete_date_format_type_form', 5),
-    'access arguments' => array('administer site configuration'),
-    'file' => 'system.admin.inc',
-  );
-  $items['admin/config/regional/date-time/formats'] = array(
     'title' => 'Formats',
     'description' => 'Configure display format strings for date and time.',
     'page callback' => 'system_date_time_formats',
     'access arguments' => array('administer site configuration'),
-    'type' => MENU_LOCAL_TASK,
     'weight' => -9,
     'file' => 'system.admin.inc',
   );
@@ -2302,24 +2264,6 @@ function system_filetransfer_info() {
  * Implements hook_init().
  */
 function system_init() {
-  global $conf;
-
-  $language_interface = language(LANGUAGE_TYPE_INTERFACE);
-  // For each date type (e.g. long, short), get the localized date format
-  // for the user's current language and override the default setting for it
-  // in $conf. This should happen on all pages except the date and time formats
-  // settings page, where we want to display the site default and not the
-  // localized version.
-  if (strpos(current_path(), 'admin/config/regional/date-time/formats') !== 0) {
-    $languages = array($language_interface->langcode);
-
-    // Setup appropriate date formats for this locale.
-    $formats = system_get_localized_date_format($languages);
-    foreach ($formats as $format_type => $format) {
-      $conf[$format_type] = $format;
-    }
-  }
-
   $path = drupal_get_path('module', 'system');
   // Add the CSS for this module. These aren't in system.info, because they
   // need to be in the CSS_SYSTEM group rather than the CSS_DEFAULT group.
@@ -2365,52 +2309,14 @@ function system_init() {
  *   An array of date formats.
  */
 function system_get_localized_date_format($languages) {
-  $formats = array();
-
   // Get list of different format types.
-  $format_types = system_get_date_types();
-  $short_default = variable_get('date_format_short', 'm/d/Y - H:i');
-
-  // Loop through each language until we find one with some date formats
-  // configured.
   foreach ($languages as $language) {
-    $date_formats = system_date_format_locale($language);
+    $date_formats = config('locale.config.' . $language . '.system.date')->get('formats');
     if (!empty($date_formats)) {
-      // We have locale-specific date formats, so check for their types. If
-      // we're missing a type, use the default setting instead.
-      foreach ($format_types as $type => $type_info) {
-        // If format exists for this language, use it.
-        if (!empty($date_formats[$type])) {
-          $formats['date_format_' . $type] = $date_formats[$type];
-        }
-        // 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);
-        }
-      }
-
-      // Return on the first match.
-      return $formats;
-    }
-  }
-
-  // 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');
-
-  // 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);
+      return $date_formats;
     }
   }
-
-  return $formats;
+  return array();
 }
 
 /**
@@ -2448,7 +2354,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;
@@ -2458,7 +2364,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;
   }
@@ -2468,8 +2375,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');
   }
 }
 
@@ -2477,8 +2385,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 <a href="@user-edit">account time zone setting</a>.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
   }
 }
@@ -2499,7 +2408,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.'),
   );
@@ -3154,7 +3063,7 @@ function system_system_info_alter(&$info, $file, $type) {
 }
 
 /**
- * Get the name of the default region for a given theme.
+ * Gets the name of the default region for a given theme.
  *
  * @param $theme
  *   The name of a theme.
@@ -3530,14 +3439,6 @@ function system_cache_flush() {
 }
 
 /**
- * Implements hook_rebuild().
- */
-function system_rebuild() {
-  // Rebuild list of date formats.
-  system_date_formats_rebuild();
-}
-
-/**
  * Implements hook_mail().
  */
 function system_mail($key, &$message, $params) {
@@ -3564,7 +3465,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('formats.system_long.pattern.php') . ' O', $zone)));
     }
   }
   // Sort the translated time zones alphabetically.
@@ -3709,48 +3610,6 @@ function system_run_automated_cron() {
 }
 
 /**
- * Gets the list of available date types and attributes.
- *
- * @param $type
- *   (optional) The date type name.
- *
- * @return
- *   An associative array of date type information keyed by the date type name.
- *   Each date type information array has the following elements:
- *   - type: The machine-readable name of the date type.
- *   - title: The human-readable name of the date type.
- *   - locked: A boolean indicating whether or not this date type should be
- *     configurable from the user interface.
- *   - module: The name of the module that defined this date type in its
- *     hook_date_format_types(). An empty string if the date type was
- *     user-defined.
- *   - is_new: A boolean indicating whether or not this date type is as of yet
- *     unsaved in the database.
- *   If $type was defined, only a single associative array with the above
- *   elements is returned.
- */
-function system_get_date_types($type = NULL) {
-  $types = &drupal_static(__FUNCTION__);
-
-  if (!isset($types)) {
-    $types = _system_date_format_types_build();
-  }
-
-  return $type ? (isset($types[$type]) ? $types[$type] : FALSE) : $types;
-}
-
-/**
- * Implements hook_date_format_types().
- */
-function system_date_format_types() {
-  return array(
-    'long' => t('Long'),
-    'medium' => t('Medium'),
-    'short' => t('Short'),
-  );
-}
-
-/**
  * Implements hook_date_formats().
  */
 function system_date_formats() {
@@ -3761,73 +3620,52 @@ function system_date_formats() {
 /**
  * Gets the list of defined date formats and attributes.
  *
- * @param $type
+ * @param $date_format_id
  *   (optional) The date type name.
  *
  * @return
- *   An associative array of date formats. The top-level keys are the names of
- *   the date types that the date formats belong to. The values are in turn
- *   associative arrays keyed by the format string, with the following keys:
- *   - dfid: The date format ID.
- *   - format: The format string.
- *   - type: The machine-readable name of the date type.
- *   - locales: An array of language codes. This can include both 2 character
- *     language codes like 'en and 'fr' and 5 character language codes like
- *     'en-gb' and 'en-us'.
- *   - locked: A boolean indicating whether or not this date type should be
- *     configurable from the user interface.
- *   - module: The name of the module that defined this date format in its
- *     hook_date_formats(). An empty string if the format was user-defined.
- *   - is_new: A boolean indicating whether or not this date type is as of yet
- *     unsaved in the database.
- *   If $type was defined, only the date formats associated with the given date
- *   type are returned, in a single associative array keyed by format string.
- */
-function system_get_date_formats($type = NULL) {
-  $date_formats = &drupal_static(__FUNCTION__);
+ *   An associative array of date formats. The top-level keys are the
+ *   machine-readable names of the date formats. The values are associative
+ *   arrays with the following keys:
+ *   - name: The human readable name of the date format.
+ *   - pattern: The pattern that will modify the format of the date
 
-  if (!isset($date_formats)) {
-    $date_formats = _system_date_formats_build();
-  }
+ *   If $date_format_id was defined, only the date formats associated with the
+ *   given machine name are returned, in a single associative array keyed by
+ *   format string.
+ */
+function system_get_date_formats($date_format_id = NULL) {
+  $date_formats = config('system.date')->get('formats');
 
-  return $type ? (isset($date_formats[$type]) ? $date_formats[$type] : FALSE) : $date_formats;
+  // Return either the specific format or all formats.
+  return empty($date_format_id) ? $date_formats : $date_formats[$date_format_id];
 }
 
 /**
- * Gets the format details for a particular format ID.
+ * Gets the appropriate date format pattern for this server's php configuration.
  *
- * @param $dfid
- *   A date format ID.
+ * @param array $pattern
+ *   The date pattern information that is stored in configuration
  *
- * @return
- *   A date format object with the following properties:
- *   - dfid: The date format ID.
- *   - format: The date format string.
- *   - type: The name of the date type.
- *   - locked: Whether the date format can be changed or not.
+ * @return string
+ *   The date format pattern
  */
-function system_get_date_format($dfid) {
-  return db_query('SELECT df.dfid, df.format, df.type, df.locked FROM {date_formats} df WHERE df.dfid = :dfid', array(':dfid' => $dfid))->fetch();
+function system_get_date_format_pattern($pattern) {
+  return $pattern[system_get_date_format_pattern_type()];
 }
 
 /**
- * Resets the database cache of date formats and saves all new date formats.
+ * Gets the appropriate date format pattern type.
+ *
+ * For now this function defaults to php.
+ *
+ * @return string
+ *   The format type.
+ *
+ * @todo: extend function to provide the appropriate key for alternate date formats
  */
-function system_date_formats_rebuild() {
-  drupal_static_reset('system_get_date_formats');
-  $date_formats = system_get_date_formats(NULL);
-
-  foreach ($date_formats as $type => $formats) {
-    foreach ($formats as $format => $info) {
-      system_date_format_save($info);
-    }
-  }
-
-  // Rebuild configured date formats locale list.
-  drupal_static_reset('system_date_format_locale');
-  system_date_format_locale();
-
-  _system_date_formats_build();
+function system_get_date_format_pattern_type() {
+  return 'php';
 }
 
 /**
@@ -3837,31 +3675,24 @@ function system_date_formats_rebuild() {
  *   (optional) Language code for the current locale. This can be a 2 character
  *   language code like 'en' and 'fr' or a 5 character language code like
  *   'en-gb' and 'en-us'.
- * @param $type
- *   (optional) The date type name.
+ * @param $date_format_id
+ *   (optional) The machine name for the date format.
  *
  * @return
- *   If $type and $langcode are specified, returns the corresponding date format
- *   string. If only $langcode is specified, returns an array of all date
- *   format strings for that locale, keyed by the date type. If neither is
- *   specified, or if no matching formats are found, returns FALSE.
+ *   If $date_format_id and $langcode are specified, returns the corresponding
+ *   date format string. If only $langcode is specified, returns an array of
+ *   all date format strings for that locale, keyed by the date type. If
+ *   neither is specified.
  */
-function system_date_format_locale($langcode = NULL, $type = NULL) {
+function system_date_format_locale($langcode = NULL, $date_format_id = NULL) {
   $formats = &drupal_static(__FUNCTION__);
 
-  if (empty($formats)) {
-    $formats = array();
-    $result = db_query("SELECT format, type, language FROM {date_format_locale}");
-    foreach ($result as $record) {
-      if (!isset($formats[$record->language])) {
-        $formats[$record->language] = array();
-      }
-      $formats[$record->language][$record->type] = $record->format;
-    }
+  if (!isset($formats[$langcode])) {
+    $formats[$langcode] = config('locale.config.' . $langcode . '.system.date')->get('formats');
   }
 
-  if ($type && $langcode && !empty($formats[$langcode][$type])) {
-    return $formats[$langcode][$type];
+  if ($date_format_id && $langcode && !empty($formats[$langcode][$date_format_id])) {
+    return $formats[$langcode][$date_format_id];
   }
   elseif ($langcode && !empty($formats[$langcode])) {
     return $formats[$langcode];
@@ -3871,244 +3702,39 @@ function system_date_format_locale($langcode = NULL, $type = NULL) {
 }
 
 /**
- * Builds and returns information about available date types.
- *
- * @return
- *   An associative array of date type information keyed by name. Each date type
- *   information array has the following elements:
- *   - type: The machine-readable name of the date type.
- *   - title: The human-readable name of the date type.
- *   - locked: A boolean indicating whether or not this date type should be
- *     configurable from the user interface.
- *   - module: The name of the module that defined this format in its
- *     hook_date_format_types(). An empty string if the format was user-defined.
- *   - is_new: A boolean indicating whether or not this date type is as of yet
- *     unsaved in the database.
- */
-function _system_date_format_types_build() {
-  $types = array();
-
-  // Get list of modules that implement hook_date_format_types().
-  $modules = module_implements('date_format_types');
-
-  foreach ($modules as $module) {
-    $module_types = module_invoke($module, 'date_format_types');
-    foreach ($module_types as $module_type => $type_title) {
-      $type = array();
-      $type['module'] = $module;
-      $type['type'] = $module_type;
-      $type['title'] = $type_title;
-      $type['locked'] = 1;
-      // Will be over-ridden later if in the db.
-      $type['is_new'] = TRUE;
-      $types[$module_type] = $type;
-    }
-  }
-
-  // Get custom formats added to the database by the end user.
-  $result = db_query('SELECT dft.type, dft.title, dft.locked FROM {date_format_type} dft ORDER BY dft.title');
-  foreach ($result as $record) {
-    if (!isset($types[$record->type])) {
-      $type = array();
-      $type['is_new'] = FALSE;
-      $type['module'] = '';
-      $type['type'] = $record->type;
-      $type['title'] = $record->title;
-      $type['locked'] = $record->locked;
-      $types[$record->type] = $type;
-    }
-    else {
-      $type = array();
-      $type['is_new'] = FALSE;  // Over-riding previous setting.
-      $types[$record->type] = array_merge($types[$record->type], $type);
-    }
-  }
-
-  // Allow other modules to modify these date types.
-  drupal_alter('date_format_types', $types);
-
-  return $types;
-}
-
-/**
- * Builds and returns information about available date formats.
- *
- * @return
- *   An associative array of date formats. The top-level keys are the names of
- *   the date types that the date formats belong to. The values are in turn
- *   associative arrays keyed by format with the following keys:
- *   - dfid: The date format ID.
- *   - format: The PHP date format string.
- *   - type: The machine-readable name of the date type the format belongs to.
- *   - locales: An array of language codes. This can include both 2 character
- *     language codes like 'en and 'fr' and 5 character language codes like
- *     'en-gb' and 'en-us'.
- *   - locked: A boolean indicating whether or not this date type should be
- *     configurable from the user interface.
- *   - module: The name of the module that defined this format in its
- *     hook_date_formats(). An empty string if the format was user-defined.
- *   - is_new: A boolean indicating whether or not this date type is as of yet
- *     unsaved in the database.
- */
-function _system_date_formats_build() {
-  $date_formats = array();
-
-  // First handle hook_date_format_types().
-  $types = _system_date_format_types_build();
-  foreach ($types as $type => $info) {
-    system_date_format_type_save($info);
-  }
-
-  // Get formats supplied by various contrib modules.
-  $module_formats = module_invoke_all('date_formats');
-
-  foreach ($module_formats as $module_format) {
-    // System types are locked.
-    $module_format['locked'] = 1;
-    // If no date type is specified, assign 'custom'.
-    if (!isset($module_format['type'])) {
-      $module_format['type'] = 'custom';
-    }
-    if (!in_array($module_format['type'], array_keys($types))) {
-      continue;
-    }
-    if (!isset($date_formats[$module_format['type']])) {
-      $date_formats[$module_format['type']] = array();
-    }
-
-    // If another module already set this format, merge in the new settings.
-    if (isset($date_formats[$module_format['type']][$module_format['format']])) {
-      $date_formats[$module_format['type']][$module_format['format']] = array_merge_recursive($date_formats[$module_format['type']][$module_format['format']], $module_format);
-    }
-    else {
-      // This setting will be overridden later if it already exists in the db.
-      $module_format['is_new'] = TRUE;
-      $date_formats[$module_format['type']][$module_format['format']] = $module_format;
-    }
-  }
-
-  // Get custom formats added to the database by the end user.
-  $result = db_query('SELECT df.dfid, df.format, df.type, df.locked, dfl.language FROM {date_formats} df LEFT JOIN {date_format_locale} dfl ON df.format = dfl.format AND df.type = dfl.type ORDER BY df.type, df.format');
-  foreach ($result as $record) {
-    // If this date type isn't set, initialise the array.
-    if (!isset($date_formats[$record->type])) {
-      $date_formats[$record->type] = array();
-    }
-    $format = (array) $record;
-    $format['is_new'] = FALSE; // It's in the db, so override this setting.
-    // If this format not already present, add it to the array.
-    if (!isset($date_formats[$record->type][$record->format])) {
-      $format['module'] = '';
-      $format['locales'] = array($record->language);
-      $date_formats[$record->type][$record->format] = $format;
-    }
-    // Format already present, so merge in settings.
-    else {
-      if (!empty($record->language)) {
-        $format['locales'] = array_merge($date_formats[$record->type][$record->format]['locales'], array($record->language));
-      }
-      $date_formats[$record->type][$record->format] = array_merge($date_formats[$record->type][$record->format], $format);
-    }
-  }
-
-  // Allow other modules to modify these formats.
-  drupal_alter('date_formats', $date_formats);
-
-  return $date_formats;
-}
-
-/**
- * Saves a date type to the database.
- *
- * @param $type
- *   A date type array containing the following keys:
- *   - type: The machine-readable name of the date type.
- *   - title: The human-readable name of the date type.
- *   - locked: A boolean indicating whether or not this date type should be
- *     configurable from the user interface.
- *   - is_new: A boolean indicating whether or not this date type is as of yet
- *     unsaved in the database.
- */
-function system_date_format_type_save($type) {
-  $info = array();
-  $info['type'] = $type['type'];
-  $info['title'] = $type['title'];
-  $info['locked'] = $type['locked'];
-
-  // Update date_format table.
-  if (!empty($type['is_new'])) {
-    drupal_write_record('date_format_type', $info);
-  }
-  else {
-    drupal_write_record('date_format_type', $info, 'type');
-  }
-}
-
-/**
- * Deletes a date type from the database.
- *
- * @param $type
- *   The machine-readable name of the date type.
- */
-function system_date_format_type_delete($type) {
-  db_delete('date_formats')
-    ->condition('type', $type)
-    ->execute();
-  db_delete('date_format_type')
-    ->condition('type', $type)
-    ->execute();
-  db_delete('date_format_locale')
-    ->condition('type', $type)
-    ->execute();
-}
-
-/**
  * Saves a date format to the database.
  *
  * @param $date_format
  *   A date format array containing the following keys:
- *   - type: The name of the date type this format is associated with.
- *   - format: The PHP date format string.
+ *   - name: The name of the date type this format is associated with.
+ *   - pattern: The PHP date format string.
  *   - locked: A boolean indicating whether or not this format should be
  *     configurable from the user interface.
- * @param $dfid
+ * @param $date_format_id
  *   If set, replace the existing date format having this ID with the
  *   information specified in $date_format.
  *
- * @see system_get_date_types()
  * @see http://php.net/date
  */
-function system_date_format_save($date_format, $dfid = 0) {
-  $info = array();
-  $info['dfid'] = $dfid;
-  $info['type'] = $date_format['type'];
-  $info['format'] = $date_format['format'];
-  $info['locked'] = $date_format['locked'];
-
-  // Update date_format table.
-  if (!empty($date_format['is_new'])) {
-    drupal_write_record('date_formats', $info);
-  }
-  else {
-    $keys = ($dfid ? array('dfid') : array('format', 'type'));
-    drupal_write_record('date_formats', $info, $keys);
-  }
+function system_date_format_save($date_format_id, $format_info) {
+  config('system.date')
+    ->set('formats.' . $date_format_id, $format_info)
+    ->save();
 
   $languages = language_list();
 
-  $locale_format = array();
-  $locale_format['type'] = $date_format['type'];
-  $locale_format['format'] = $date_format['format'];
+  $locale_format = array(
+    'name' => $format_info['name'],
+    'pattern' => $format_info['pattern'],
+  );
 
   // Check if the suggested language codes are configured.
-  if (!empty($date_format['locales'])) {
-    foreach ($date_format['locales'] as $langcode) {
+  if (!empty($format_info['locales'])) {
+    foreach ($format_info['locales'] as $langcode) {
       if (isset($languages[$langcode])) {
-        $is_existing = (bool) db_query_range('SELECT 1 FROM {date_format_locale} WHERE type = :type AND language = :language', 0, 1, array(':type' => $date_format['type'], ':language' => $langcode))->fetchField();
-        if (!$is_existing) {
-          $locale_format['language'] = $langcode;
-          drupal_write_record('date_format_locale', $locale_format);
-        }
+        config('locale.config.' . $langcode . '.system.date')
+          ->set('formats.' . $date_format_id, $locale_format)
+          ->save();
       }
     }
   }
@@ -4117,13 +3743,20 @@ function system_date_format_save($date_format, $dfid = 0) {
 /**
  * Deletes a date format from the database.
  *
- * @param $dfid
+ * @param $date_format_id
  *   The date format ID.
  */
-function system_date_format_delete($dfid) {
-  db_delete('date_formats')
-    ->condition('dfid', $dfid)
-    ->execute();
+function system_date_format_delete($date_format_id) {
+  $format_id = 'formats.' . $date_format_id;
+  config('system.date')->clear($format_id)->save();
+
+  // Clean up the localized entry if required.
+  foreach (language_list() as $langcode => $data) {
+    $config = config('locale.config.' . $langcode . '.system.date');
+    if ($config->get($format_id)) {
+      $config->clear($format_id)->save();
+    }
+  }
 }
 
 /**
diff --git a/core/modules/system/system.tokens.inc b/core/modules/system/system.tokens.inc
index a5e7ad2..12876a8 100644
--- a/core/modules/system/system.tokens.inc
+++ b/core/modules/system/system.tokens.inc
@@ -55,15 +55,15 @@ function system_token_info() {
   // Date related tokens.
   $date['short'] = array(
     'name' => t("Short format"),
-    'description' => t("A date in 'short' format. (%date)", array('%date' => format_date(REQUEST_TIME, 'short'))),
+    'description' => t("A date in 'short' format. (%date)", array('%date' => format_date(REQUEST_TIME, 'system_short'))),
   );
   $date['medium'] = array(
     'name' => t("Medium format"),
-    'description' => t("A date in 'medium' format. (%date)", array('%date' => format_date(REQUEST_TIME, 'medium'))),
+    'description' => t("A date in 'medium' format. (%date)", array('%date' => format_date(REQUEST_TIME, 'system_medium'))),
   );
   $date['long'] = array(
     'name' => t("Long format"),
-    'description' => t("A date in 'long' format. (%date)", array('%date' => format_date(REQUEST_TIME, 'long'))),
+    'description' => t("A date in 'long' format. (%date)", array('%date' => format_date(REQUEST_TIME, 'system_long'))),
   );
   $date['custom'] = array(
     'name' => t("Custom format"),
@@ -184,15 +184,15 @@ function system_tokens($type, $tokens, array $data = array(), array $options = a
     foreach ($tokens as $name => $original) {
       switch ($name) {
         case 'short':
-          $replacements[$original] = format_date($date, 'short', '', NULL, $langcode);
+          $replacements[$original] = format_date($date, 'system_short', '', NULL, $langcode);
           break;
 
         case 'medium':
-          $replacements[$original] = format_date($date, 'medium', '', NULL, $langcode);
+          $replacements[$original] = format_date($date, 'system_medium', '', NULL, $langcode);
           break;
 
         case 'long':
-          $replacements[$original] = format_date($date, 'long', '', NULL, $langcode);
+          $replacements[$original] = format_date($date, 'system_long', '', NULL, $langcode);
           break;
 
         case 'since':
@@ -245,7 +245,7 @@ function system_tokens($type, $tokens, array $data = array(), array $options = a
 
         // These tokens are default variations on the chained tokens handled below.
         case 'timestamp':
-          $replacements[$original] = format_date($file->timestamp, 'medium', '', NULL, $langcode);
+          $replacements[$original] = format_date($file->timestamp, 'system_medium', '', NULL, $langcode);
           break;
 
         case 'owner':
diff --git a/core/modules/user/config/user.settings.yml b/core/modules/user/config/user.settings.yml
index efc0e4b..b4c8a58 100644
--- a/core/modules/user/config/user.settings.yml
+++ b/core/modules/user/config/user.settings.yml
@@ -13,3 +13,4 @@ notify:
 register: visitors
 signatures: '0'
 cancel_method: user_cancel_block
+password_reset_timeout: '86400'
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php b/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php
index 96ac5de..bb70f78 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php
@@ -41,10 +41,8 @@ function testUserPasswordReset() {
    * Attempts login using an expired password reset link.
    */
   function testUserPasswordResetExpired() {
-    // Set password reset timeout variable to 43200 seconds = 12 hours.
-    $timeout = 43200;
-    variable_set('user_password_reset_timeout', $timeout);
-
+    // Set password reset timeout to 43200 seconds = 12 hours.
+    config('user.settings')->set('password_reset_timeout', 43200)->save();
     // Create a user.
     $account = $this->drupalCreateUser();
     $this->drupalLogin($account);
@@ -54,7 +52,8 @@ function testUserPasswordResetExpired() {
 
     // To attempt an expired password reset, create a password reset link as if
     // its request time was 60 seconds older than the allowed limit of timeout.
-    $bogus_timestamp = REQUEST_TIME - variable_get('user_password_reset_timeout', 86400) - 60;
+    $timeout = config('user.settings')->get('password_reset_timeout');
+    $bogus_timestamp = REQUEST_TIME - $timeout - 60;
     $this->drupalGet("user/reset/$account->uid/$bogus_timestamp/" . user_pass_rehash($account->pass, $bogus_timestamp, $account->login));
     $this->assertText(t('You have tried to use a one-time login link that has expired. Please request a new one using the form below.'), 'Expired password reset request rejected.');
   }
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
index 9c518d7..9a94cd9 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 @@ function testRegistrationEmailDuplicates() {
   }
 
   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 @@ function testRegistrationDefaultValues() {
     $this->assertEqual($new_user->theme, '', 'Correct theme field.');
     $this->assertEqual($new_user->signature, '', 'Correct signature field.');
     $this->assertTrue(($new_user->created > REQUEST_TIME - 20 ), 'Correct creation time.');
-    $this->assertEqual($new_user->status, $config->get('register') == USER_REGISTER_VISITORS ? 1 : 0, 'Correct status field.');
-    $this->assertEqual($new_user->timezone, variable_get('date_default_timezone'), 'Correct time zone field.');
+    $this->assertEqual($new_user->status, $config_user_settings->get('register') == USER_REGISTER_VISITORS ? 1 : 0, 'Correct status field.');
+    $this->assertEqual($new_user->timezone, $config_system_date->get('timezone.default'), 'Correct time zone field.');
     $this->assertEqual($new_user->langcode, language_default()->langcode, 'Correct language field.');
     $this->assertEqual($new_user->preferred_langcode, language_default()->langcode, 'Correct preferred language field.');
     $this->assertEqual($new_user->picture, 0, '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 f692706..ba170b8 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 @@ public static function getInfo() {
    */
   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('formats.system_medium.pattern.php', 'Y-m-d H:i T')
+      ->save();
 
     // Create a user account and login.
     $web_user = $this->drupalCreateUser();
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
index d14e826..87f9959 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
@@ -65,10 +65,10 @@ function testUserTokenReplacement() {
     $tests['[user:mail]'] = check_plain($account->mail);
     $tests['[user:url]'] = url("user/$account->uid", $url_options);
     $tests['[user:edit-url]'] = url("user/$account->uid/edit", $url_options);
-    $tests['[user:last-login]'] = format_date($account->login, 'medium', '', NULL, $language_interface->langcode);
-    $tests['[user:last-login:short]'] = format_date($account->login, 'short', '', NULL, $language_interface->langcode);
-    $tests['[user:created]'] = format_date($account->created, 'medium', '', NULL, $language_interface->langcode);
-    $tests['[user:created:short]'] = format_date($account->created, 'short', '', NULL, $language_interface->langcode);
+    $tests['[user:last-login]'] = format_date($account->login, 'system_medium', '', NULL, $language_interface->langcode);
+    $tests['[user:last-login:short]'] = format_date($account->login, 'system_short', '', NULL, $language_interface->langcode);
+    $tests['[user:created]'] = format_date($account->created, 'system_medium', '', NULL, $language_interface->langcode);
+    $tests['[user:created:short]'] = format_date($account->created, 'system_short', '', NULL, $language_interface->langcode);
     $tests['[current-user:name]'] = check_plain(user_format_name($global_account));
 
     // Test to make sure that we generated something for each token.
diff --git a/core/modules/user/user.api.php b/core/modules/user/user.api.php
index 0c3002c..5abb44c 100644
--- a/core/modules/user/user.api.php
+++ b/core/modules/user/user.api.php
@@ -313,8 +313,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 <a href="@user-edit">account time zone setting</a>.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
   }
 }
diff --git a/core/modules/user/user.install b/core/modules/user/user.install
index d5c3e4a..520ad8e 100644
--- a/core/modules/user/user.install
+++ b/core/modules/user/user.install
@@ -496,6 +496,7 @@ function user_update_8004() {
     'user_mail_status_blocked_notify' => 'notify.status_blocked',
     'user_mail_status_cancelled_notify' => 'notify.status_cancelled',
     'user_email_verification' => 'verify_mail',
+    'user_password_reset_timeout' => 'password_reset_timeout',
   ));
 
   // Convert the user.settings:register numeric value to text value.
diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc
index 1fd8aa5..20af863 100644
--- a/core/modules/user/user.pages.inc
+++ b/core/modules/user/user.pages.inc
@@ -119,9 +119,8 @@ function user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $a
     drupal_goto();
   }
   else {
-    // Time out, in seconds, until login URL expires. Defaults to 24 hours =
-    // 86400 seconds.
-    $timeout = variable_get('user_password_reset_timeout', 86400);
+    // Time out, in seconds, until login URL expires.
+    $timeout = config('user.settings')->get('password_reset_timeout');
     $current = REQUEST_TIME;
     $account = user_load($uid);
     // Verify that the user exists and is active.
diff --git a/core/modules/user/user.tokens.inc b/core/modules/user/user.tokens.inc
index bc37434..30d984b 100644
--- a/core/modules/user/user.tokens.inc
+++ b/core/modules/user/user.tokens.inc
@@ -103,12 +103,12 @@ function user_tokens($type, $tokens, array $data = array(), array $options = arr
 
         // These tokens are default variations on the chained tokens handled below.
         case 'last-login':
-          $replacements[$original] = !empty($account->login) ? format_date($account->login, 'medium', '', NULL, $langcode) : t('never');
+          $replacements[$original] = !empty($account->login) ? format_date($account->login, 'system_medium', '', NULL, $langcode) : t('never');
           break;
 
         case 'created':
           // In the case of user_presave the created date may not yet be set.
-          $replacements[$original] = !empty($account->created) ? format_date($account->created, 'medium', '', NULL, $langcode) : t('not yet created');
+          $replacements[$original] = !empty($account->created) ? format_date($account->created, 'system_medium', '', NULL, $langcode) : t('not yet created');
           break;
       }
     }
diff --git a/core/modules/views/config/views.view.glossary.yml b/core/modules/views/config/views.view.glossary.yml
index 966da7c..4d0d274 100644
--- a/core/modules/views/config/views.view.glossary.yml
+++ b/core/modules/views/config/views.view.glossary.yml
@@ -47,7 +47,7 @@ display:
           table: node
           field: changed
           label: 'Last update'
-          date_format: large
+          date_format: system_long
       arguments:
         title:
           id: title
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php
index e67614e..8424dbc 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php
@@ -742,13 +742,7 @@ public function getSQLDateField() {
    * Figure out what timezone we're in; needed for some date manipulations.
    */
   public static function getTimezone() {
-    global $user;
-    if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
-      $timezone = $user->timezone;
-    }
-    else {
-      $timezone = variable_get('date_default_timezone', 0);
-    }
+    $timezone = drupal_get_user_timezone();
 
     // set up the database timezone
     $db_type = Database::getConnection()->databaseType();
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/cache/None.php b/core/modules/views/lib/Drupal/views/Plugin/views/cache/None.php
index 89e1703..eed62c6 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/cache/None.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/cache/None.php
@@ -29,10 +29,22 @@ public function summaryTitle() {
     return t('None');
   }
 
+
+  /**
+   * Overrides \Drupal\views\Plugin\views\cache\CachePluginBase::cache_get().
+   *
+   * Replace the cache get logic so it does not return a cache item at all.
+   */
   function cache_get($type) {
     return FALSE;
   }
 
-  function cache_set($type) { }
+  /**
+   * Overrides \Drupal\views\Plugin\views\cache\CachePluginBase::cache_set().
+   *
+   * Replace the cache set logic so it does set a cache item at all.
+   */
+  function cache_set($type) {
+  }
 
 }
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
index cf68a49..46e79e1 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
@@ -89,6 +89,13 @@
    */
   protected $usesAttachments = FALSE;
 
+  /**
+   * Whether the display allows area plugins.
+   *
+   * @var bool
+   */
+  protected $usesAreas = TRUE;
+
   public function init(ViewExecutable $view, &$display, $options = NULL) {
     $this->setOptionDefaults($this->options, $this->defineOptions());
     $this->view = &$view;
@@ -360,6 +367,16 @@ public function usesAttachments() {
   }
 
   /**
+   * Returns whether the display can use areas.
+   *
+   * @return bool
+   *   TRUE if the display can use areas, or FALSE otherwise.
+   */
+  public function usesAreas() {
+    return $this->usesAreas;
+  }
+
+  /**
    * Allow displays to attach to other views.
    */
   public function attachTo($display_id) { }
@@ -2195,7 +2212,7 @@ public function submitOptionsForm(&$form, &$form_state) {
         }
         break;
       case 'query':
-        $plugin = $this->get_plugin('query');
+        $plugin = $this->getPlugin('query');
         if ($plugin) {
           $plugin->submitOptionsForm($form['query']['options'], $form_state);
           $this->setOption('query', $form_state['values'][$section]);
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/field/Date.php b/core/modules/views/lib/Drupal/views/Plugin/views/field/Date.php
index dd5f2fa..e898593 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/field/Date.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/field/Date.php
@@ -33,9 +33,9 @@ protected function defineOptions() {
   public function buildOptionsForm(&$form, &$form_state) {
 
     $date_formats = array();
-    $date_types = system_get_date_types();
-    foreach ($date_types as $key => $value) {
-      $date_formats[$value['type']] = check_plain(t($value['title'] . ' format')) . ': ' . format_date(REQUEST_TIME, $value['type']);
+    $date_types = system_get_date_formats();
+    foreach ($date_types as $machine_name => $value) {
+      $date_formats[$machine_name] = check_plain(t('@name format', array('@name' => $value['name'])) . ': ' . format_date(REQUEST_TIME, $machine_name));
     }
 
     $form['date_format'] = array(
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php b/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php
index 991d38e..43e52ca 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php
@@ -246,7 +246,6 @@ public function buildOptionsForm(&$form, &$form_state) {
       '#default_value' => implode(', ', $this->options['query_tags']),
       '#element_validate' => array('views_element_validate_tags'),
     );
-    $form_state['build_info']['files']['foo'] = drupal_get_path('module', 'views') . '/lib/Drupal/views/Plugin/Query/SqlQuery.php';
   }
 
   /**
diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldDateTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldDateTest.php
index 6040d40..f7f1a10 100644
--- a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldDateTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldDateTest.php
@@ -56,9 +56,9 @@ public function testFieldDate() {
     );
     foreach ($timezones as $timezone) {
       $dates = array(
-        'small' => format_date($time, 'small', '', $timezone),
-        'medium' => format_date($time, 'medium', '', $timezone),
-        'large' => format_date($time, 'large', '', $timezone),
+        'small' => format_date($time, 'system_small', '', $timezone),
+        'medium' => format_date($time, 'system_medium', '', $timezone),
+        'large' => format_date($time, 'system_large', '', $timezone),
         'custom' => format_date($time, 'custom', 'c', $timezone),
       );
       $this->assertRenderedDatesEqual($view, $dates, $timezone);
diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerAllTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerAllTest.php
index 93529ab..85861cd 100644
--- a/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerAllTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerAllTest.php
@@ -95,7 +95,12 @@ public function testHandlers() {
       foreach ($object_types as $type) {
         if (isset($view->{$type})) {
           foreach ($view->{$type} as $handler) {
-            $this->assertTrue($handler instanceof HandlerBase);
+            $this->assertTrue($handler instanceof HandlerBase, format_string(
+              '@type handler of class %class is an instance of HandlerBase',
+              array(
+                '@type' => $type,
+                '%class' => get_class($handler),
+              )));
           }
         }
       }
diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/AccessTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/AccessTest.php
index 195106f..066e648 100644
--- a/core/modules/views/lib/Drupal/views/Tests/Plugin/AccessTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/AccessTest.php
@@ -91,8 +91,8 @@ function testDynamicAccessPlugin() {
     $view = $this->createViewFromConfig('test_access_dynamic');
     $argument1 = $this->randomName();
     $argument2 = $this->randomName();
-    variable_set('test_dynamic_access_argument1', $argument1);
-    variable_set('test_dynamic_access_argument2', $argument2);
+    state()->set('test_dynamic_access_argument1', $argument1);
+    state()->set('test_dynamic_access_argument2', $argument2);
 
     $access_plugin = $view->display_handler->getPlugin('access');
 
diff --git a/core/modules/views/lib/Drupal/views/Tests/UI/DefaultViewsTest.php b/core/modules/views/lib/Drupal/views/Tests/UI/DefaultViewsTest.php
index 73d6184..770f1bf 100644
--- a/core/modules/views/lib/Drupal/views/Tests/UI/DefaultViewsTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/UI/DefaultViewsTest.php
@@ -87,6 +87,15 @@ function testDefaultViews() {
     $this->clickViewsOperationLink(t('Enable'), '/frontpage/');
     $this->assertUrl('admin/structure/views');
     $this->assertLinkByHref($edit_href);
+
+    // Test deleting a view.
+    $this->drupalGet('admin/structure/views');
+    $this->clickViewsOperationLink(t('Delete'), '/frontpage/');
+    // Submit the confirmation form.
+    $this->drupalPost(NULL, array(), t('Delete'));
+    // Ensure the view is no longer listed.
+    $this->assertUrl('admin/structure/views');
+    $this->assertNoLinkByHref($edit_href);
   }
 
   /**
diff --git a/core/modules/views/lib/Drupal/views/Tests/UI/DisplayTest.php b/core/modules/views/lib/Drupal/views/Tests/UI/DisplayTest.php
index 0fd4bc3..a3dc979 100644
--- a/core/modules/views/lib/Drupal/views/Tests/UI/DisplayTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/UI/DisplayTest.php
@@ -128,7 +128,7 @@ public function testReorderDisplay() {
    */
   public function testDefaultDisplay() {
     $this->drupalGet('admin/structure/views/view/test_display');
-    $elements = $this->xpath('//*[@id="views-page-display-title"]');
+    $elements = $this->xpath('//*[@id="views-page-1-display-title"]');
     $this->assertEqual(count($elements), 1, 'The page display is loaded as the default display.');
   }
 
@@ -182,4 +182,32 @@ public function testDisplayPluginsAlter() {
     }
   }
 
+  /**
+   * Tests display areas.
+   */
+  public function testDisplayAreas() {
+    // Show the advanced column.
+    config('views.settings')->set('ui.show.advanced_column', TRUE)->save();
+
+    // Add a new data display to the view.
+    $view = views_get_view('test_display');
+    $view->storage->addDisplay('display_no_area_test');
+    $view->save();
+
+    $this->drupalGet('admin/structure/views/view/test_display/edit/display_no_area_test_1');
+
+    // Create a mapping of area type => class.
+    $areas = array(
+      'header' => 'header',
+      'footer' => 'footer',
+      'empty' => 'no-results-behavior',
+    );
+
+    // Assert that the expected text is found in each area category.
+    foreach ($areas as $type => $class) {
+      $element = $this->xpath('//div[contains(@class, :class)]/div', array(':class' => $class));
+      $this->assertEqual((string) $element[0], "The selected display type does not utilize $type plugins");
+    }
+  }
+
 }
diff --git a/core/modules/views/lib/Drupal/views/Tests/UI/HandlerTest.php b/core/modules/views/lib/Drupal/views/Tests/UI/HandlerTest.php
new file mode 100644
index 0000000..808776c
--- /dev/null
+++ b/core/modules/views/lib/Drupal/views/Tests/UI/HandlerTest.php
@@ -0,0 +1,62 @@
+<?php
+
+/**
+ * @file
+ * Contains Drupal\views\Tests\UI\HandlerTest.
+ */
+
+namespace Drupal\views\Tests\UI;
+
+use Drupal\views\ViewExecutable;
+
+/**
+ * Tests some generic handler UI functionality.
+ *
+ * @see \Drupal\views\Plugin\views\HandlerBase
+ */
+class HandlerTest extends UITestBase {
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Handler test',
+      'description' => 'Tests handler UI for views.',
+      'group' => 'Views UI'
+    );
+  }
+
+  /**
+   * Tests UI CRUD.
+   */
+  public function testUICRUD() {
+    $handler_types = ViewExecutable::viewsHandlerTypes();
+    foreach ($handler_types as $type => $type_info) {
+      // Test adding handlers.
+      $add_handler_url = "admin/structure/views/nojs/add-item/test_view/default/$type";
+
+      // Area handler types need to use a different handler.
+      if (in_array($type, array('header', 'footer', 'empty'))) {
+        $this->drupalPost($add_handler_url, array('name[views.area]' => TRUE), t('Add and configure @handler', array('@handler' => $type_info['ltitle'])));
+        $edit_handler_url = "admin/structure/views/nojs/config-item/test_view/default/$type/area";
+      }
+      elseif ($type == 'relationship') {
+        // @todo Add a views_test_data relationship handler to test.
+        continue;
+      }
+      else {
+        $this->drupalPost($add_handler_url, array('name[views_test_data.job]' => TRUE), t('Add and configure @handler', array('@handler' => $type_info['ltitle'])));
+        $edit_handler_url = "admin/structure/views/nojs/config-item/test_view/default/$type/job";
+      }
+
+      $this->assertUrl($edit_handler_url, array(), 'The user got redirected to the handler edit form.');
+      $this->drupalPost(NULL, array(), t('Apply'));
+
+      $this->assertUrl('admin/structure/views/view/test_view/edit', array(), 'The user got redirected to the views edit form.');
+
+      $this->assertLinkByHref($edit_handler_url, 0, 'The handler edit link appears in the UI.');
+
+      $this->drupalPost($edit_handler_url, array(), t('Remove'));
+      $this->assertNoLinkByHref($edit_handler_url, 0, 'The handler edit link does not appears in the UI after removing.');
+    }
+  }
+
+}
diff --git a/core/modules/views/lib/Drupal/views/Tests/UI/QueryTest.php b/core/modules/views/lib/Drupal/views/Tests/UI/QueryTest.php
new file mode 100644
index 0000000..83f0bfa
--- /dev/null
+++ b/core/modules/views/lib/Drupal/views/Tests/UI/QueryTest.php
@@ -0,0 +1,53 @@
+<?php
+
+/**
+ * @file
+ * Definition of Drupal\views\Tests\UI\QueryTest.
+ */
+
+namespace Drupal\views\Tests\UI;
+
+use Drupal\views\Tests\ViewTestBase;
+use Drupal\views_test_data\Plugin\views\query\QueryTest as QueryTestPlugin;
+
+/**
+ * Tests query plugins.
+ */
+class QueryTest extends UITestBase {
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Query: UI',
+      'description' => 'Tests query plugins UI.',
+      'group' => 'Views UI'
+    );
+  }
+
+  /**
+   * Overrides \Drupal\views\Tests\ViewTestBase::viewsData().
+   */
+  protected function viewsData() {
+    $data = parent::viewsData();
+    $data['views_test_data']['table']['base']['query_id'] = 'query_test';
+
+    return $data;
+  }
+
+  /**
+   * Tests query plugins settings.
+   */
+  public function testQueryUI() {
+    // Save some query settings.
+    $query_settings_path = "admin/structure/views/nojs/display/test_view/default/query";
+    $random_value = $this->randomName();
+    $this->drupalPost($query_settings_path, array('query[options][test_setting]' => $random_value), t('Apply'));
+    $this->drupalPost(NULL, array(), t('Save'));
+
+    // Check that the settings are saved into the view itself.
+    $view = views_get_view('test_view');
+    $view->initDisplay();
+    $view->initQuery();
+    $this->assertEqual($random_value, $view->query->options['test_setting'], 'Query settings got saved');
+  }
+
+}
diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php b/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php
index 4ad233d..751d62b 100644
--- a/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php
+++ b/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php
@@ -6,7 +6,6 @@
 
 namespace Drupal\views\Tests;
 
-use Drupal\views\ViewExecutable;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -42,8 +41,8 @@ protected function setUp() {
    */
   protected function enableViewsTestModule() {
     // Define the schema and views data variable before enabling the test module.
-    variable_set('views_test_data_schema', $this->schemaDefinition());
-    variable_set('views_test_data_views_data', $this->viewsData());
+    state()->set('views_test_data_schema', $this->schemaDefinition());
+    state()->set('views_test_data_views_data', $this->viewsData());
 
     module_enable(array('views_test_data'));
     $this->resetAll();
diff --git a/core/modules/views/lib/Drupal/views/ViewExecutable.php b/core/modules/views/lib/Drupal/views/ViewExecutable.php
index 0f9837d..4e59f7f 100644
--- a/core/modules/views/lib/Drupal/views/ViewExecutable.php
+++ b/core/modules/views/lib/Drupal/views/ViewExecutable.php
@@ -1184,12 +1184,12 @@ public function execute($display_id = NULL) {
 
     // Check for already-cached results.
     if (!empty($this->live_preview)) {
-      $cache = FALSE;
+      $cache = $this->display_handler->getPlugin('cache', 'none');
     }
     else {
       $cache = $this->display_handler->getPlugin('cache');
     }
-    if ($cache && $cache->cache_get('results')) {
+    if ($cache->cache_get('results')) {
       if ($this->pager->use_pager()) {
         $this->pager->total_items = $this->total_rows;
         $this->pager->update_page_info();
@@ -1201,9 +1201,7 @@ public function execute($display_id = NULL) {
       // views_plugin_query::execute().
       $this->result = array_values($this->result);
       $this->_postExecute();
-      if ($cache) {
-        $cache->cache_set('results');
-      }
+      $cache->cache_set('results');
     }
 
     // Let modules modify the view just after executing it.
diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_display.yml b/core/modules/views/tests/views_test_config/config/views.view.test_display.yml
index 5c44bb2..d9c5430 100644
--- a/core/modules/views/tests/views_test_config/config/views.view.test_display.yml
+++ b/core/modules/views/tests/views_test_config/config/views.view.test_display.yml
@@ -75,12 +75,12 @@ display:
     display_title: Master
     id: default
     position: '0'
-  page:
+  page_1:
     display_options:
       path: test-display
     display_plugin: page
     display_title: Page
-    id: page
+    id: page_1
     position: '1'
 human_name: ''
 name: test_display
diff --git a/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/access/DynamicTest.php b/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/access/DynamicTest.php
index 1704661..d8d0b83 100644
--- a/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/access/DynamicTest.php
+++ b/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/access/DynamicTest.php
@@ -30,7 +30,7 @@ protected function defineOptions() {
   }
 
   public function access($account) {
-    return !empty($this->options['access']) && isset($this->view->args[0]) && $this->view->args[0] == variable_get('test_dynamic_access_argument1', NULL) && isset($this->view->args[1]) && $this->view->args[1] == variable_get('test_dynamic_access_argument2', NULL);
+    return !empty($this->options['access']) && isset($this->view->args[0]) && $this->view->args[0] == state()->get('test_dynamic_access_argument1') && isset($this->view->args[1]) && $this->view->args[1] == state()->get('test_dynamic_access_argument2');
   }
 
   function get_access_callback() {
diff --git a/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/display/DisplayNoAreaTest.php b/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/display/DisplayNoAreaTest.php
new file mode 100644
index 0000000..46398ab
--- /dev/null
+++ b/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/display/DisplayNoAreaTest.php
@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * @file
+ * Definition of Drupal\views_test_data\Plugin\views\display\DisplayNoAreaTest.
+ */
+
+namespace Drupal\views_test_data\Plugin\views\display;
+
+use Drupal\Core\Annotation\Plugin;
+use Drupal\Core\Annotation\Translation;
+
+/**
+ * Defines a Display test plugin with areas disabled.
+ *
+ * @Plugin(
+ *   id = "display_no_area_test",
+ *   title = @Translation("Display test no area"),
+ *   theme = "views_view",
+ *   contextual_links_locations = {"view"}
+ * )
+ */
+class DisplayNoAreaTest extends DisplayTest {
+
+  /**
+   * Whether the display allows area plugins.
+   *
+   * @var bool
+   *   TRUE if the display can use areas, or FALSE otherwise.
+   */
+  protected $usesAreas = FALSE;
+
+}
diff --git a/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/query/QueryTest.php b/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/query/QueryTest.php
index eab54df..4ee2a48 100644
--- a/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/query/QueryTest.php
+++ b/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/query/QueryTest.php
@@ -28,6 +28,29 @@ class QueryTest extends QueryPluginBase {
   protected $orderBy = array();
 
   /**
+   * Implements \Drupal\views\Plugin\views\query\QueryPluginBase::defineOptions().
+   */
+  protected function defineOptions() {
+    $options = parent::defineOptions();
+    $options['test_setting'] = array('default' => '');
+
+    return $options;
+  }
+
+  /**
+   * Implements \Drupal\views\Plugin\views\query\QueryPluginBase::buildOptionsForm().
+   */
+  public function buildOptionsForm(&$form, &$form_state) {
+    parent::buildOptionsForm($form, $form_state);
+
+    $form['test_setting'] = array(
+      '#title' => t('Test setting'),
+      '#type' => 'textfield',
+      '#default_value' => $this->options['test_setting'],
+    );
+  }
+
+  /**
    * Sets the allItems property.
    *
    * @param array $allItems
diff --git a/core/modules/views/tests/views_test_data/views_test_data.install b/core/modules/views/tests/views_test_data/views_test_data.install
index bb13531..520796d 100644
--- a/core/modules/views/tests/views_test_data/views_test_data.install
+++ b/core/modules/views/tests/views_test_data/views_test_data.install
@@ -9,7 +9,7 @@
  * Implements hook_schema().
  */
 function views_test_data_schema() {
-  return variable_get('views_test_data_schema', array());
+  return state()->get('views_test_data_schema');
 }
 
 /**
diff --git a/core/modules/views/tests/views_test_data/views_test_data.module b/core/modules/views/tests/views_test_data/views_test_data.module
index bf813e8..fd15d7a 100644
--- a/core/modules/views/tests/views_test_data/views_test_data.module
+++ b/core/modules/views/tests/views_test_data/views_test_data.module
@@ -23,7 +23,7 @@ function views_test_data_permission() {
  * Implements hook_views_data().
  */
 function views_test_data_views_data() {
-  return variable_get('views_test_data_views_data', array());
+  return state()->get('views_test_data_views_data');
 }
 
 function views_test_data_test_static_access_callback($access) {
@@ -31,7 +31,7 @@ function views_test_data_test_static_access_callback($access) {
 }
 
 function views_test_data_test_dynamic_access_callback($access, $argument1, $argument2) {
-  return $access && $argument1 == variable_get('test_dynamic_access_argument1', NULL) && $argument2 == variable_get('test_dynamic_access_argument2', NULL);
+  return $access && $argument1 == state()->get('test_dynamic_access_argument1') && $argument2 == state()->get('test_dynamic_access_argument2');
 }
 
 /**+
diff --git a/core/modules/views/views.module b/core/modules/views/views.module
index c29136a..6608d47 100644
--- a/core/modules/views/views.module
+++ b/core/modules/views/views.module
@@ -669,9 +669,9 @@ function views_block_info() {
   }
 
   // Only save hashes if they have changed.
-  $old_hashes = variable_get('views_block_hashes', array());
+  $old_hashes = state()->get('views_block_hashes');
   if ($hashes != $old_hashes) {
-    variable_set('views_block_hashes', $hashes);
+    state()->set('views_block_hashes', $hashes);
   }
 
   views_cache_set('views_block_items', $items, TRUE);
@@ -686,7 +686,7 @@ function views_block_view($delta) {
   $start = microtime(TRUE);
   // if this is 32, this should be an md5 hash.
   if (strlen($delta) == 32) {
-    $hashes = variable_get('views_block_hashes', array());
+    $hashes = state()->get('views_block_hashes');
     if (!empty($hashes[$delta])) {
       $delta = $hashes[$delta];
     }
diff --git a/core/modules/views/views_ui/css/views-admin.bartik-rtl.css b/core/modules/views/views_ui/css/views-admin.bartik-rtl.css
deleted file mode 100644
index db382d5..0000000
--- a/core/modules/views/views_ui/css/views-admin.bartik-rtl.css
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * The .bartik.css file is intended to contain styles that override declarations
- * in the Bartik theme.
- */
-
- /* @group Lists */
-
-.views-display-top .secondary .action-list {
-  padding-left: inherit;
-  padding-right: 0;
-}
-
-/* @end */
-
-/* @group Collapsible */
-
-.views-display-columns fieldset .fieldset-legend {
-  padding: 0 2px 4px 0;
-}
-
-/* @end */
diff --git a/core/modules/views/views_ui/css/views-admin.bartik.css b/core/modules/views/views_ui/css/views-admin.bartik.css
deleted file mode 100644
index c05e0ef..0000000
--- a/core/modules/views/views_ui/css/views-admin.bartik.css
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * The .bartik.css file is intended to contain styles that override declarations
- * in the Bartik theme.
- */
-
-/* @group Lists */
-
-.views-display-top .secondary .action-list {
-  padding-left: 0; /* LTR */
-}
-
-/* @end */
-
-/* @group Attachment details tabs
- *
- * The tabs that switch between sections
- */
-
-.views-displays .region-content .secondary,
-.views-displays .region-content .secondary {
-  padding-bottom: 0;
-  padding-left: 0;
-}
-
-.views-displays .secondary a {
-  font-size: smaller;
-}
-
-.views-displays .secondary > li a {
-  border-radius: 5px;
-}
-
-.views-displays .secondary > li.open a {
-  border-radius: 5px 5px 0 0;
-}
-
-.views-displays .secondary .open > a:hover {
-  color: #0071B3;
-}
-
-.views-displays .secondary input.form-submit {
-  font-size: smaller;
-}
-
-/* @end */
-
-/* @group Modal dialog box
- *
- * The contents of the popup dialog on the views edit form.
- */
-
-.views-filterable-options .even .form-type-checkbox {
-  background-color: #F9F9F9;
-}
-
-.views-ui-dialog .ui-dialog-titlebar-close,
-.views-ui-dialog #views-ajax-title,
-.views-ui-dialog .views-override,
-.views-ui-dialog .form-buttons {
-  background-color: #f6f6f6;
-}
-
-.views-ui-dialog a {
-  color: #0071b3;
-}
-
-.views-ui-dialog a:hover,
-.views-ui-dialog a:focus {
-  color: #018fe2;
-}
-
-/* @end */
-
-.views-display-column .fieldset-wrapper {
-  margin-top: 0;
-}
-
-.views-display-column fieldset legend {
-  background: none;
-  border: none;
-  font-family: inherit;
-  font-size: 13px;
-  line-height: inherit;
-  position: relative;
-  text-indent: 0;
-  text-shadow: none;
-  top: 3px;
-}
-
-.views-display-columns fieldset {
-  position: inherit;
-}
-
-.views-display-columns fieldset .fieldset-legend {
-  padding: 0 0 4px 2px; /* LTR */
-}
-
-.views-display-columns a.fieldset-title {
-  color: #0071B3;
-}
-
-.views-display-columns a.fieldset-title:hover {
-  color: #018FE2;
-}
-
-/* @group Dropbutton */
-
-.views-ui-display-tab-actions .dropbutton input {
-  color: #0071B3;
-}
-
-.views-ui-display-tab-actions .dropbutton input:hover,
-.views-ui-display-tab-actions .dropbutton input:focus {
-  color: #018FE2;
-}
-
-.views-ui-display-tab-actions .dropbutton input.form-submit {
-  margin-right: 0;
-  margin-top: 0;
-}
-
-/* @end */
diff --git a/core/modules/views/views_ui/css/views-admin.seven-rtl.css b/core/modules/views/views_ui/css/views-admin.seven-rtl.css
deleted file mode 100644
index abdd5aa..0000000
--- a/core/modules/views/views_ui/css/views-admin.seven-rtl.css
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * The .seven.css file is intended to contain styles that override declarations
- * in the Seven admin theme.
- */
-
-/* @group Forms */
-
-.views-admin .form-submit,
-.views-admin a.button {
-  margin-left: 0;
-}
-
-/* @end */
-
-/* @group Lists */
-
-.views-admin .links li {
-  padding-left: 0;
-}
-
-/* @end */
-
-/* @group Attachments */
-
-.views-displays .secondary {
-  text-align: right;
-}
-
-/* @end */
-
-/* @group Attachment details tabs */
-
-.views-display-top ul.secondary {
-  float: right;
-}
-
-.views-displays .secondary .action-list  li:first-child {
-  -moz-border-radius: 7px 0 0 0;
-  -webkit-border-radius: 7px 0 0 0;
-  border-radius: 7px 0 0 0;
-}
-
-/* @end */
diff --git a/core/modules/views/views_ui/css/views-admin.seven.css b/core/modules/views/views_ui/css/views-admin.seven.css
deleted file mode 100644
index 6b57ca2..0000000
--- a/core/modules/views/views_ui/css/views-admin.seven.css
+++ /dev/null
@@ -1,376 +0,0 @@
-/**
- * The .seven.css file is intended to contain styles that override declarations
- * in the Seven admin theme.
- */
-
-/* @group Content */
-
-.views-ui-display-tab-bucket h1,
-.views-ui-display-tab-bucket h2,
-.views-ui-display-tab-bucket h3,
-.views-ui-display-tab-bucket h4,
-.views-ui-display-tab-bucket h5 {
-  margin-bottom: 0;
-  margin-top: 0;
-}
-
-/* @end */
-
-/* @group Forms */
-
-.views-ui-dialog fieldset {
-  padding-top: 2.5em;
-}
-
-fieldset fieldset {
-  border: medium none;
-}
-
-/**
- * Seven positions the legend absolutely, but does not have a way to ignore
- * fieldsets without a legend so we make one up.
- */
-fieldset.fieldset-no-legend {
-  padding-top: 0;
-}
-
-/**
- * Being extra safe here and scoping this to the add view wizard form (where
- * a layout problem occurs for the Display format fieldset if we don't fix its
- * padding), but it's probably safe to just let it apply everywhere.
- */
-#views-ui-add-form fieldset fieldset .fieldset-wrapper {
-  padding-left: 0;
-  padding-right: 0;
-}
-
-.views-display-tab fieldset.box-padding .fieldset-wrapper {
-  padding: 0;
-}
-
-.views-admin .form-item label.option,
-#views-ui-preview-form .form-item label.option {
-  font-size: 1em;
-}
-
-#views-ui-preview-form .form-submit {
-  margin-top: 3px;
-}
-
-.views-admin input.form-submit,
-.views-ui-dialog input.form-submit,
-.views-admin a.button,
-.views-ui-dialog a.button {
-  margin-bottom: 0;
-  margin-right: 0; /* LTR */
-  margin-top: 0;
-}
-
-/* Override for a button on the edit display screen */
-#edit-displays-preview-controls .form-submit {
-  display: inline-block;
-  margin-right: 1em;
-}
-
-.form-item,
-.form-item .form-item {
-  margin-bottom: 0;
-  margin-top: 9px;
-  padding-bottom: 0;
-  padding-top: 0;
-}
-
-.form-actions {
-  margin-bottom: 0;
-  margin-top: 0;
-}
-
-.form-item .form-item {
-  padding-bottom: 0;
-  padding-top: 0;
-}
-
-.form-radios > .form-item {
-  margin-top: 3px;
-}
-
-/* @group Dependent options
- */
-
-/* This is necessary to supercede the Seven .form-item
- * reset declaration that sets the margin to zero.
- */
-.form-item-options-expose-required,
-.form-item-options-expose-label,
-.form-item-options-expose-description {
-  margin-left: 1.5em;
-}
-
-.views-admin-dependent .form-item .form-item,
-.views-admin-dependent .form-type-checkboxes,
-.views-admin-dependent .form-type-radios,
-.views-admin-dependent .form-item .form-item,
-.form-item-options-expose-required,
-.form-item-options-expose-label,
-.form-item-options-expose-description {
-  margin-bottom: 6px;
-  margin-top: 6px;
-}
-
-.views-admin-dependent .form-type-radio,
-.views-admin-dependent .form-radios .form-item {
-  margin-bottom: 2px;
-  margin-top: 2px;
-}
-
-/* @end */
-
-/* @group Lists */
-
-.views-admin ul.secondary,
-.views-admin .item-list ul {
-  margin: 0;
-  padding: 0;
-}
-
-.views-admin ul.secondary {
-  clear: none;
-}
-
-.views-displays ul.secondary li a,
-.views-displays ul.secondary li.active a,
-.views-displays ul.secondary li.active a.active {
-  padding: 2px 7px 3px;
-}
-
-.views-displays ul.secondary li.active a,
-.views-displays ul.secondary li.active a.active {
-  border: 1px solid transparent;
-}
-
-.views-admin .links li {
-  padding-right: 0; /* LTR */
-}
-
-.views-admin .button .links li {
-  padding-right: 12px; /* LTR */
-}
-
-.page-admin-structure-views #content ul.action-links {
-  padding-left: 0;
-  padding-right: 0;
-}
-
-.views-display-top ul.secondary {
-  background-color: transparent;
-  float: left
-}
-
-.views-display-top .secondary .action-list li {
-  float: none;
-  margin: 0;
-}
-
-/* @end */
-
-/* @group Tables */
-
-table td,
-table th {
-  vertical-align: top;
-}
-
-/* @end */
-
-/* @group Attachment details */
-
-#edit-display-settings-title {
-  color: #008BCB;
-}
-
-/* @end */
-
-/* @group Attachment details tabs
- *
- * The tabs that switch between sections
- */
-
-.views-displays .secondary {
- text-align: left; /* LTR */
-}
-
-.views-displays .secondary > li:first-child {
- padding-left: 0;
-}
-
-.views-admin .icon.add {
-  background-position: center 3px;
-}
-
-.views-displays .secondary a {
-  background-color: #f1f1f1;
-  border-radius: 7px;
-  color: #008BCB;
-}
-
-.views-displays .secondary a:hover > .icon.add {
-  background-position: center -25px;
-}
-
-.views-displays .secondary .open > a {
-  -moz-border-radius: 7px 7px 0 0;
-  -webkit-border-radius: 7px 7px 0 0;
-  border-radius: 7px 7px 0 0;
-}
-
-.views-displays .secondary .open > a:hover {
-  background-color: #f1f1f1;
-  color: #008BCB;
-}
-
-.views-displays .secondary .action-list  li:first-child {
-  -moz-border-radius: 0 7px 0 0;
-  -webkit-border-radius: 0 7px 0 0;
-  border-radius: 0 7px 0 0;
-}
-
-.views-displays .secondary .action-list  li:last-child {
-  -moz-border-radius: 0 0 7px 7px;
-  -webkit-border-radius: 0 0 7px 7px;
-  border-radius: 0 0 7px 7px;
-}
-
-.views-displays .secondary .action-list input.form-submit {
-  -moz-border-radius: 0;
-  -webkit-border-radius: 0;
-  border-radius: 0;
-  color: #008BCB;
-}
-
-/* @end */
-
-/* @group Attachment buckets
- *
- * These are the individual "buckets," or boxes, inside the display settings area
- */
-
-.views-ui-display-tab-bucket h3 {
-  font-size: 12px;
-  text-transform: uppercase;
-}
-
-.views-ui-display-tab-bucket .links {
-  padding: 2px 6px 4px;
-}
-
-.views-ui-display-tab-bucket .links li + li {
-  margin-left: 3px;
-}
-
-/* @end */
-
-/* @group Rearrange filter criteria */
-
-#views-ui-rearrange-filter-form .action-links {
-  margin: 0;
-  padding: 0;
-}
-
-#views-ui-rearrange-filter-form table {
-  border: medium none;
-}
-
-#views-ui-rearrange-filter-form [id^="views-row"] {
-  border: medium none;
-}
-
-#views-ui-rearrange-filter-form tr td:last-child {
-  border-right: medium none;
-}
-
-#views-ui-rearrange-filter-form .filter-group-operator-row {
-  border-left: 1px solid transparent !important;
-  border-right: 1px solid transparent !important;
-}
-
-#views-ui-rearrange-filter-form tr.drag td {
-  background-color: #FFEE77 !important;
-}
-
-#views-ui-rearrange-filter-form tr.drag-previous td {
-  background-color: #FFFFBB !important;
-}
-
-/* @end */
-
-/* @group Live preview elements */
-
-.views-query-info pre {
-  margin-bottom: 0;
-  margin-top: 0;
-}
-
-/* @group Query info table */
-
-.views-query-info table {
-  -moz-border-radius: 7px;
-  -webkit-border-radius: 7px;
-  border-radius: 7px;
-  -webkit-border-horizontal-spacing: 1px;
-  -webkit-border-vertical-spacing: 1px;
-}
-
-.views-query-info table tr td:last-child {
-  /* Fixes a Seven style that bleeds down into this table unnecessarily */
-  border-right: 0 none;
-}
-
-/* @end */
-
-/* @end */
-
-/* @group Add view */
-
-.form-item-page-create,
-.form-item-block-create {
-  margin-top: 13px;
-}
-
-/* @end */
-
-/* @group Modal dialog box
- *
- * The contents of the popup dialog on the views edit form.
- */
-
-.views-ui-dialog .ui-dialog-titlebar-close {
-  -moz-box-shadow: none;
-  -webkit-box-shadow: none;
-  box-shadow: none;
-  border-color: #cccccc;
-  right: -27px;
-  top: -1px;
-}
-
-.views-ui-dialog fieldset.collapsible {
-  padding-top: 1.5em;
-}
-
-.views-ui-dialog fieldset.collapsed {
-  padding-top: 2.5em;
-}
-
-.filterable-option .form-item.form-type-checkbox {
-  /* This selector is aggressive because Seven's reset for .form-items is aggressive. */
-  padding-bottom: 4px;
-  padding-left: 4px;
-  padding-top: 4px;
-}
-
-/* @end */
-
-.views-ui-display-tab-actions .dropbutton-wrapper input {
-  color: #0074BD;
-}
-
-/* @end */
diff --git a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewEditFormController.php b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewEditFormController.php
index b9d966b..853d5c9 100644
--- a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewEditFormController.php
+++ b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewEditFormController.php
@@ -317,9 +317,9 @@ public function getDisplayTab($view) {
     // If the plugin doesn't exist, display an error message instead of an edit
     // page.
     if (empty($display)) {
-      $title = isset($display['display_title']) ? $display['display_title'] : t('Invalid');
+      $title = isset($display->display['display_title']) ? $display->display['display_title'] : t('Invalid');
       // @TODO: Improved UX for the case where a plugin is missing.
-      $build['#markup'] = t("Error: Display @display refers to a plugin named '@plugin', but that plugin is not available.", array('@display' => $display['id'], '@plugin' => $display['display_plugin']));
+      $build['#markup'] = t("Error: Display @display refers to a plugin named '@plugin', but that plugin is not available.", array('@display' => $display->display['id'], '@plugin' => $display->display['display_plugin']));
     }
     // Build the content of the edit page.
     else {
@@ -592,12 +592,13 @@ public function submitDisplayDelete($form, &$form_state) {
    * Regenerate the current tab for AJAX updates.
    */
   public function rebuildCurrentTab(ViewUI $view, &$output, $display_id) {
+    $view->displayID = $display_id;
     if (!$view->get('executable')->setDisplay('default')) {
       return;
     }
 
     // Regenerate the main display area.
-    $build = static::getDisplayTab($this);
+    $build = $this->getDisplayTab($view);
     static::addMicroweights($build);
     $output[] = ajax_command_html('#views-tab-' . $display_id, drupal_render($build));
 
@@ -612,7 +613,7 @@ public function rebuildCurrentTab(ViewUI $view, &$output, $display_id) {
    */
   public function renderDisplayTop(ViewUI $view) {
     $display_id = $view->displayID;
-    $element['#theme'] = 'views_ui_container';
+    $element['#theme_wrappers'][] = 'views_ui_container';
     $element['#attributes']['class'] = array('views-display-top', 'clearfix');
     $element['#attributes']['id'] = array('views-display-top');
 
@@ -835,7 +836,17 @@ public function getFormBucket(ViewUI $view, $type, $display) {
           );
           return $build;
         }
-
+      case 'header':
+      case 'footer':
+      case 'empty':
+        if (!$view->get('executable')->displayHandlers[$display['id']]->usesAreas()) {
+          $build[$type][] = array(
+            '#markup' => t('The selected display type does not utilize @type plugins', array('@type' => $type)),
+            '#theme_wrappers' => array('views_ui_container'),
+            '#attributes' => array('class' => array('views-display-setting')),
+          );
+          return $build;
+        }
       default:
         $rearrange_url = "admin/structure/views/nojs/rearrange/{$view->get('name')}/{$display['id']}/$type";
         $rearrange_text = t('Rearrange');
diff --git a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewFormControllerBase.php b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewFormControllerBase.php
index aae0052..3683875 100644
--- a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewFormControllerBase.php
+++ b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewFormControllerBase.php
@@ -61,32 +61,6 @@ public static function getAdminCSS() {
     $list[$module_path . '/css/views-admin.css'] = array();
     $list[$module_path . '/css/views-admin.theme.css'] = array();
 
-    // Add in any theme specific CSS files we have
-    $themes = list_themes();
-    $theme_key = $GLOBALS['theme'];
-    while ($theme_key) {
-      // Try to find the admin css file for non-core themes.
-      if (!in_array($theme_key, array('seven', 'bartik'))) {
-        $theme_path = drupal_get_path('theme', $theme_key);
-        // First search in the css directory, then in the root folder of the theme.
-        if (file_exists($theme_path . "/css/views-admin.$theme_key.css")) {
-          $list[$theme_path . "/css/views-admin.$theme_key.css"] = array(
-            'group' => CSS_THEME,
-          );
-        }
-        elseif (file_exists($theme_path . "/views-admin.$theme_key.css")) {
-          $list[$theme_path . "/views-admin.$theme_key.css"] = array(
-            'group' => CSS_THEME,
-          );
-        }
-      }
-      else {
-        $list[$module_path . "/css/views-admin.$theme_key.css"] = array(
-          'group' => CSS_THEME,
-        );
-      }
-      $theme_key = isset($themes[$theme_key]->base_theme) ? $themes[$theme_key]->base_theme : '';
-    }
     if (module_exists('contextual')) {
       $list[$module_path . '/css/views-admin.contextual.css'] = array();
     }
diff --git a/core/modules/views/views_ui/theme/theme.inc b/core/modules/views/views_ui/theme/theme.inc
index 0a1e66f..530aec5 100644
--- a/core/modules/views/views_ui/theme/theme.inc
+++ b/core/modules/views/views_ui/theme/theme.inc
@@ -12,7 +12,7 @@
  */
 function theme_views_ui_container($variables) {
   $element = $variables['element'];
-  return '<div' . new Attribute($element['#attributes']) . '>' . drupal_render_children($element) . '</div>';
+  return '<div' . new Attribute($element['#attributes']) . '>' . $element['#children'] . '</div>';
 }
 
 function template_preprocess_views_ui_display_tab_setting(&$variables) {
diff --git a/core/modules/views/views_ui/views_ui.module b/core/modules/views/views_ui/views_ui.module
index 90f8aaf..feb6553 100644
--- a/core/modules/views/views_ui/views_ui.module
+++ b/core/modules/views/views_ui/views_ui.module
@@ -57,6 +57,13 @@ function views_ui_menu() {
     'title' => 'Disable a view',
   ) + $ajax_base;
 
+  $items['admin/structure/views/view/%views_ui/delete'] = array(
+    'title' => 'Delete a view',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('views_ui_confirm_delete', 4),
+    'type' => MENU_CALLBACK,
+  ) + $base;
+
   $items['admin/structure/views/settings'] = array(
     'title' => 'Settings',
     'page callback' => 'drupal_get_form',
@@ -753,6 +760,33 @@ function views_ui_ajax_callback(ViewExecutable $view, $op) {
 }
 
 /**
+ * Form constructor for the View deletion form.
+ *
+ * @param \Drupal\views\ViewExectuable $view
+ *   The View being deleted.
+ *
+ * @see views_ui_confirm_delete_submit()
+ */
+function views_ui_confirm_delete($form, &$form_state, ViewExecutable $view) {
+  $form['view'] = array('#type' => 'value', '#value' => $view);
+  return confirm_form($form,
+    t('Are you sure you want to delete the %name view?', array('%name' => $view->storage->getHumanName())),
+    'admin/structure/views',
+    t('This action cannot be undone.'),
+    t('Delete'),
+    t('Cancel')
+  );
+}
+
+/**
+ * Form submission handler for views_ui_confirm_delete().
+ */
+function views_ui_confirm_delete_submit($form, &$form_state) {
+  $form_state['values']['view']->storage->delete();
+  $form_state['redirect'] = 'admin/structure/views';
+}
+
+/**
  * Page callback: Lists all of the views.
  *
  * @return array
diff --git a/core/themes/bartik/css/style-rtl.css b/core/themes/bartik/css/style-rtl.css
index 90638eb..703a8f8 100644
--- a/core/themes/bartik/css/style-rtl.css
+++ b/core/themes/bartik/css/style-rtl.css
@@ -279,3 +279,22 @@ ul.action-links li a {
   right: -20px;
   left: 0;
 }
+
+/* ---------- Views styling ---------- */
+
+ /* @group Lists */
+
+.views-display-top .secondary .action-list {
+  padding-left: inherit;
+  padding-right: 0;
+}
+
+/* @end */
+
+/* @group Collapsible */
+
+.views-display-columns fieldset .fieldset-legend {
+  padding: 0 2px 4px 0;
+}
+
+/* @end */
diff --git a/core/themes/bartik/css/style.css b/core/themes/bartik/css/style.css
index f0e244c..29152bb 100644
--- a/core/themes/bartik/css/style.css
+++ b/core/themes/bartik/css/style.css
@@ -1738,3 +1738,123 @@ div.admin-panel .description {
     display: none;
   }
 }
+
+/* ---------- Views styling ---------- */
+
+/* @group Lists */
+
+.views-display-top .secondary .action-list {
+  padding-left: 0; /* LTR */
+}
+
+/* @end */
+
+/* @group Attachment details tabs
+ *
+ * The tabs that switch between sections
+ */
+
+.views-displays .region-content .secondary,
+.views-displays .region-content .secondary {
+  padding-bottom: 0;
+  padding-left: 0;
+}
+
+.views-displays .secondary a {
+  font-size: smaller;
+}
+
+.views-displays .secondary > li a {
+  border-radius: 5px;
+}
+
+.views-displays .secondary > li.open a {
+  border-radius: 5px 5px 0 0;
+}
+
+.views-displays .secondary .open > a:hover {
+  color: #0071B3;
+}
+
+.views-displays .secondary input.form-submit {
+  font-size: smaller;
+}
+
+/* @end */
+
+/* @group Modal dialog box
+ *
+ * The contents of the popup dialog on the views edit form.
+ */
+
+.views-filterable-options .even .form-type-checkbox {
+  background-color: #F9F9F9;
+}
+
+.views-ui-dialog .ui-dialog-titlebar-close,
+.views-ui-dialog #views-ajax-title,
+.views-ui-dialog .views-override,
+.views-ui-dialog .form-buttons {
+  background-color: #f6f6f6;
+}
+
+.views-ui-dialog a {
+  color: #0071b3;
+}
+
+.views-ui-dialog a:hover,
+.views-ui-dialog a:focus {
+  color: #018fe2;
+}
+
+/* @end */
+
+.views-display-column .fieldset-wrapper {
+  margin-top: 0;
+}
+
+.views-display-column fieldset legend {
+  background: none;
+  border: none;
+  font-family: inherit;
+  font-size: 13px;
+  line-height: inherit;
+  position: relative;
+  text-indent: 0;
+  text-shadow: none;
+  top: 3px;
+}
+
+.views-display-columns fieldset {
+  position: inherit;
+}
+
+.views-display-columns fieldset .fieldset-legend {
+  padding: 0 0 4px 2px; /* LTR */
+}
+
+.views-display-columns a.fieldset-title {
+  color: #0071B3;
+}
+
+.views-display-columns a.fieldset-title:hover {
+  color: #018FE2;
+}
+
+/* @group Dropbutton */
+
+.views-ui-display-tab-actions .dropbutton input {
+  color: #0071B3;
+}
+
+.views-ui-display-tab-actions .dropbutton input:hover,
+.views-ui-display-tab-actions .dropbutton input:focus {
+  color: #018FE2;
+}
+
+.views-ui-display-tab-actions .dropbutton input.form-submit {
+  margin-right: 0;
+  margin-top: 0;
+}
+
+/* @end */
diff --git a/core/themes/seven/style-rtl.css b/core/themes/seven/style-rtl.css
index 788aa36..6ead7c2 100644
--- a/core/themes/seven/style-rtl.css
+++ b/core/themes/seven/style-rtl.css
@@ -209,3 +209,44 @@ div.add-or-remove-shortcuts {
 #user-login-form .openid-links .user-link {
   margin-right: 1.5em;
 }
+/**
+ * Views styling
+ */
+ /* @group Forms */
+
+.views-admin .form-submit,
+.views-admin a.button {
+  margin-left: 0;
+}
+
+/* @end */
+
+/* @group Lists */
+
+.views-admin .links li {
+  padding-left: 0;
+}
+
+/* @end */
+
+/* @group Attachments */
+
+.views-displays .secondary {
+  text-align: right;
+}
+
+/* @end */
+
+/* @group Attachment details tabs */
+
+.views-display-top ul.secondary {
+  float: right;
+}
+
+.views-displays .secondary .action-list  li:first-child {
+  -moz-border-radius: 7px 0 0 0;
+  -webkit-border-radius: 7px 0 0 0;
+  border-radius: 7px 0 0 0;
+}
+
+/* @end */
diff --git a/core/themes/seven/style.css b/core/themes/seven/style.css
index 3b5776a..a517d64 100644
--- a/core/themes/seven/style.css
+++ b/core/themes/seven/style.css
@@ -1057,9 +1057,7 @@ div.add-or-remove-shortcuts {
 .dropbutton-multiple.open .dropbutton-content li:first-child > * {
   text-overflow: clip;
 }
-.dropbutton-arrow {
-  right: 35%;
-}
+
 /* Disable overlay message */
 #overlay-disable-message {
   background-color: #addafc;
@@ -1081,3 +1079,319 @@ div.add-or-remove-shortcuts {
   color: #fff;
   border-radius: 8px;
 }
+
+/**
+ * Views styling
+ */
+
+/* @group Forms */
+
+fieldset fieldset {
+  border: medium none;
+}
+
+/**
+ * Seven positions the legend absolutely, but does not have a way to ignore
+ * fieldsets without a legend so we make one up.
+ */
+fieldset.fieldset-no-legend {
+  padding-top: 0;
+}
+
+/**
+ * Being extra safe here and scoping this to the add view wizard form (where
+ * a layout problem occurs for the Display format fieldset if we don't fix its
+ * padding), but it's probably safe to just let it apply everywhere.
+ */
+#views-ui-add-form fieldset fieldset .fieldset-wrapper {
+  padding-left: 0;
+  padding-right: 0;
+}
+
+.views-display-tab fieldset.box-padding .fieldset-wrapper {
+  padding: 0;
+}
+
+.views-admin .form-item label.option,
+#views-ui-preview-form .form-item label.option {
+  font-size: 1em;
+}
+
+#views-ui-preview-form .form-submit {
+  margin-top: 3px;
+}
+
+.views-admin input.form-submit,
+.views-ui-dialog input.form-submit,
+.views-admin a.button,
+.views-ui-dialog a.button {
+  margin-bottom: 0;
+  margin-right: 0; /* LTR */
+  margin-top: 0;
+}
+
+/* Override for a button on the edit display screen */
+#edit-displays-preview-controls .form-submit {
+  display: inline-block;
+  margin-right: 1em;
+}
+
+.form-radios > .form-item {
+  margin-top: 3px;
+}
+
+/* @group Dependent options
+ */
+
+/* This is necessary to supercede the Seven .form-item
+ * reset declaration that sets the margin to zero.
+ */
+.form-item-options-expose-required,
+.form-item-options-expose-label,
+.form-item-options-expose-description {
+  margin-left: 1.5em;
+}
+
+.views-admin-dependent .form-item .form-item,
+.views-admin-dependent .form-type-checkboxes,
+.views-admin-dependent .form-type-radios,
+.views-admin-dependent .form-item .form-item,
+.form-item-options-expose-required,
+.form-item-options-expose-label,
+.form-item-options-expose-description {
+  margin-bottom: 6px;
+  margin-top: 6px;
+}
+
+.views-admin-dependent .form-type-radio,
+.views-admin-dependent .form-radios .form-item {
+  margin-bottom: 2px;
+  margin-top: 2px;
+}
+
+/* @end */
+
+/* @group Lists */
+
+.views-admin ul.secondary,
+.views-admin .item-list ul {
+  margin: 0;
+  padding: 0;
+}
+
+.views-displays ul.secondary li a,
+.views-displays ul.secondary li.active a,
+.views-displays ul.secondary li.active a.active {
+  padding: 2px 7px 3px;
+}
+
+.views-displays ul.secondary li.active a,
+.views-displays ul.secondary li.active a.active {
+  border: 1px solid transparent;
+}
+
+.views-admin .links li {
+  padding-right: 0; /* LTR */
+}
+
+.views-admin .button .links li {
+  padding-right: 12px; /* LTR */
+}
+
+.views-display-top ul.secondary {
+  background-color: transparent;
+  float: left
+}
+
+.views-display-top .secondary .action-list li {
+  float: none;
+  margin: 0;
+}
+
+/* @end */
+
+/* @group Tables */
+
+.views-ui-rearrange-filter-form table td,
+.views-ui-rearrange-filter-form table th {
+  vertical-align: top;
+}
+
+/* @end */
+
+/* @group Attachment details */
+
+#edit-display-settings-title {
+  color: #008BCB;
+}
+
+/* @end */
+
+/* @group Attachment details tabs
+ *
+ * The tabs that switch between sections
+ */
+
+.views-displays .secondary {
+ text-align: left; /* LTR */
+}
+
+.views-admin .icon.add {
+  background-position: center 3px;
+}
+
+.views-displays .secondary a {
+  background-color: #f1f1f1;
+  color: #008BCB;
+}
+
+.views-displays .secondary a:hover > .icon.add {
+  background-position: center -25px;
+}
+
+.views-displays .secondary .open > a {
+  -moz-border-radius: 7px 7px 0 0;
+  -webkit-border-radius: 7px 7px 0 0;
+  border-radius: 7px 7px 0 0;
+}
+
+.views-displays .secondary .open > a:hover {
+  background-color: #f1f1f1;
+  color: #008BCB;
+}
+
+.views-displays .secondary .action-list  li:first-child {
+  -moz-border-radius: 0 7px 0 0;
+  -webkit-border-radius: 0 7px 0 0;
+  border-radius: 0 7px 0 0;
+}
+
+.views-displays .secondary .action-list  li:last-child {
+  -moz-border-radius: 0 0 7px 7px;
+  -webkit-border-radius: 0 0 7px 7px;
+  border-radius: 0 0 7px 7px;
+}
+
+.views-displays .secondary .action-list input.form-submit {
+  color: #008bcb;
+}
+
+/* @end */
+
+/* @group Attachment buckets
+ *
+ * These are the individual "buckets," or boxes, inside the display settings area
+ */
+
+.views-ui-display-tab-bucket h3 {
+  font-size: 12px;
+  text-transform: uppercase;
+}
+
+.views-ui-display-tab-bucket .links {
+  padding: 2px 6px 4px;
+}
+
+.views-ui-display-tab-bucket .links li + li {
+  margin-left: 3px;
+}
+
+/* @end */
+
+/* @group Rearrange filter criteria */
+
+#views-ui-rearrange-filter-form .action-links {
+  margin: 0;
+  padding: 0;
+}
+
+#views-ui-rearrange-filter-form table {
+  border: medium none;
+}
+
+#views-ui-rearrange-filter-form [id^="views-row"] {
+  border: medium none;
+}
+
+#views-ui-rearrange-filter-form tr td:last-child {
+  border-right: medium none;
+}
+
+#views-ui-rearrange-filter-form .filter-group-operator-row {
+  border-left: 1px solid transparent !important;
+  border-right: 1px solid transparent !important;
+}
+
+#views-ui-rearrange-filter-form tr.drag td {
+  background-color: #FFEE77 !important;
+}
+
+#views-ui-rearrange-filter-form tr.drag-previous td {
+  background-color: #FFFFBB !important;
+}
+
+/* @end */
+
+/* @group Live preview elements */
+
+.views-query-info pre {
+  margin-bottom: 0;
+  margin-top: 0;
+}
+
+/* @group Query info table */
+
+.views-query-info table {
+  -moz-border-radius: 7px;
+  -webkit-border-radius: 7px;
+  border-radius: 7px;
+  -webkit-border-horizontal-spacing: 1px;
+  -webkit-border-vertical-spacing: 1px;
+}
+
+.views-query-info table tr td:last-child {
+  /* Fixes a Seven style that bleeds down into this table unnecessarily */
+  border-right: 0 none;
+}
+
+/* @end */
+
+/* @end */
+
+/* @group Add view */
+
+.form-item-page-create,
+.form-item-block-create {
+  margin-top: 13px;
+}
+
+/* @end */
+
+/* @group Modal dialog box
+ *
+ * The contents of the popup dialog on the views edit form.
+ */
+
+.views-ui-dialog .ui-dialog-titlebar-close {
+  -moz-box-shadow: none;
+  -webkit-box-shadow: none;
+  box-shadow: none;
+  border-color: #cccccc;
+  right: -27px;
+  top: -1px;
+}
+
+.views-ui-dialog fieldset.collapsible:not(.collapsed) {
+  padding-top: 1.5em;
+}
+
+.filterable-option .form-item.form-type-checkbox {
+  /* This selector is aggressive because Seven's reset for .form-items is aggressive. */
+  padding-bottom: 4px;
+  padding-left: 4px;
+  padding-top: 4px;
+}
+
+/* @end */
+
+/* @end */
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
index 9b1c7ce..44993ed 100755
--- a/sites/default/default.settings.php
+++ b/sites/default/default.settings.php
@@ -476,25 +476,6 @@
 # );
 
 /**
- * IP blocking (Ban module).
- *
- * To bypass database queries for denied IP addresses, use this setting.
- * Ban module queries the {ban_ip} table by default on every page request
- * for both authenticated and anonymous users. This allows the system to
- * block IP addresses from within the administrative interface and before any
- * modules are loaded. However on high traffic websites you may want to avoid
- * this query, allowing you to bypass database access altogether for anonymous
- * users under certain caching configurations.
- *
- * If using this setting, you will need to add back any IP addresses which
- * you may have blocked via the administrative interface. Each element of this
- * array represents a blocked IP address.
- *
- * Remove the leading hash signs to enable.
- */
-# $conf['ban_ips'][] = 'a.b.c.d';
-
-/**
  * Fast 404 pages:
  *
  * Drupal can generate fully themed 404 pages. However, some of these responses
