Commit 8f04acbb authored by alexpott's avatar alexpott

Issue #2309221 by mikey_p: Drupal\Core\Datetime\Date should be renamed to DateFormatter.

parent 25627b05
......@@ -787,8 +787,8 @@ services:
country_manager:
class: Drupal\Core\Locale\CountryManager
arguments: ['@module_handler']
date:
class: Drupal\Core\Datetime\Date
date.formatter:
class: Drupal\Core\Datetime\DateFormatter
arguments: ['@entity.manager', '@language_manager', '@string_translation', '@config.factory']
feed.bridge.reader:
class: Drupal\Component\Bridge\ZfExtensionManagerSfContainer
......
......@@ -320,9 +320,9 @@ function _batch_process() {
'@total' => $total,
'@current' => floor($current),
'@percentage' => $percentage,
'@elapsed' => \Drupal::service('date')->formatInterval($elapsed / 1000),
'@elapsed' => \Drupal::service('date.formatter')->formatInterval($elapsed / 1000),
// If possible, estimate remaining processing time.
'@estimate' => ($current > 0) ? \Drupal::service('date')->formatInterval(($elapsed * ($total - $current) / $current) / 1000) : '-',
'@estimate' => ($current > 0) ? \Drupal::service('date.formatter')->formatInterval(($elapsed * ($total - $current) / $current) / 1000) : '-',
);
$message = strtr($progress_message, $values);
if (!empty($task_message)) {
......@@ -411,7 +411,7 @@ function _batch_finished() {
if (is_callable($batch_set['finished'])) {
$queue = _batch_queue($batch_set);
$operations = $queue->getAllItems();
call_user_func_array($batch_set['finished'], array($batch_set['success'], $batch_set['results'], $operations, \Drupal::service('date')->formatInterval($batch_set['elapsed'] / 1000)));
call_user_func_array($batch_set['finished'], array($batch_set['success'], $batch_set['results'], $operations, \Drupal::service('date.formatter')->formatInterval($batch_set['elapsed'] / 1000)));
}
}
}
......
......@@ -611,10 +611,10 @@ function format_size($size, $langcode = NULL) {
* @return
* A translated date string in the requested format.
*
* @see \Drupal\Component\Datetime\Date::format()
* @see \Drupal\Component\Datetime\DateFormatter::format()
*/
function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
return \Drupal::service('date')->format($timestamp, $type, $format, $timezone, $langcode);
return \Drupal::service('date.formatter')->format($timestamp, $type, $format, $timezone, $langcode);
}
/**
......
......@@ -21,7 +21,7 @@
*
* @ingroup i18n
*/
class Date {
class DateFormatter {
use StringTranslationTrait;
/**
......
......@@ -33,9 +33,10 @@ public function __construct($environment, ClassLoader $class_loader) {
parent::__construct($environment, $class_loader, FALSE);
// Prime the module list and corresponding Extension objects.
// @todo Remove System module. Needed because \Drupal\Core\Datetime\Date
// has a (needless) dependency on the 'date_format' entity, so calls to
// format_date()/format_interval() cause a plugin not found exception.
// @todo Remove System module. Needed because
// \Drupal\Core\Datetime\DateFormatter has a (needless) dependency on the
// 'date_format' entity, so calls to format_date()/format_interval() cause
// a plugin not found exception.
$this->moduleList = array(
'system' => 0,
'simpletest' => 0,
......
......@@ -33,7 +33,7 @@ function template_preprocess_aggregator_item(&$variables) {
$variables['source_title'] = String::checkPlain($item->ftitle);
}
if (date('Ymd', $item->getPostedTime()) == date('Ymd')) {
$variables['source_date'] = t('%ago ago', array('%ago' => \Drupal::service('date')->formatInterval(REQUEST_TIME - $item->getPostedTime())));
$variables['source_date'] = t('%ago ago', array('%ago' => \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $item->getPostedTime())));
}
else {
$variables['source_date'] = format_date($item->getPostedTime(), 'medium');
......@@ -121,7 +121,7 @@ function template_preprocess_aggregator_summary_item(&$variables) {
'datetime' => format_date($item->getPostedTime(), 'html_datetime', '', 'UTC'),
'class' => array('feed-item-age',),
),
'#text' => t('%age old', array('%age' => \Drupal::service('date')->formatInterval(REQUEST_TIME - $item->getPostedTime()))),
'#text' => t('%age old', array('%age' => \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $item->getPostedTime()))),
'#html' => TRUE,
);
}
......@@ -161,7 +161,7 @@ function template_preprocess_aggregator_feed_source(&$variables) {
$variables['source_url'] = check_url(url($feed->getWebsiteUrl(), array('absolute' => TRUE)));
if ($feed->checked) {
$variables['last_checked'] = t('@time ago', array('@time' => \Drupal::service('date')->formatInterval(REQUEST_TIME - $feed->getLastCheckedTime())));
$variables['last_checked'] = t('@time ago', array('@time' => \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $feed->getLastCheckedTime())));
}
else {
$variables['last_checked'] = t('never');
......
......@@ -9,7 +9,7 @@
use Drupal\Component\Utility\Xss;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\aggregator\FeedInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
......@@ -23,14 +23,14 @@ class AggregatorController extends ControllerBase {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\Date
* @var \Drupal\Core\Datetime\DateFormatter
*/
protected $dateFormatter;
/**
* Constructs a \Drupal\aggregator\Controller\AggregatorController object.
*
* @param \Drupal\Core\Datetime\Date $date_formatter
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* The date formatter service.
*/
public function __construct(DateFormatter $date_formatter) {
......@@ -42,7 +42,7 @@ public function __construct(DateFormatter $date_formatter) {
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('date')
$container->get('date.formatter')
);
}
......
......@@ -162,7 +162,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
));
$intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200);
$period = array_map(array(\Drupal::service('date'), 'formatInterval'), array_combine($intervals, $intervals));
$period = array_map(array(\Drupal::service('date.formatter'), 'formatInterval'), array_combine($intervals, $intervals));
$period[AGGREGATOR_CLEAR_NEVER] = t('Never');
$fields['refresh'] = FieldDefinition::create('list_integer')
......
......@@ -69,7 +69,7 @@ public function getFormId() {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200);
$period = array_map(array(\Drupal::service('date'), 'formatInterval'), array_combine($intervals, $intervals));
$period = array_map(array(\Drupal::service('date.formatter'), 'formatInterval'), array_combine($intervals, $intervals));
$form['upload'] = array(
'#type' => 'file',
......
......@@ -13,7 +13,7 @@
use Drupal\aggregator\FeedInterface;
use Drupal\Core\Database\Database;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Entity\Query\QueryInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
......@@ -56,7 +56,7 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\Date
* @var \Drupal\Core\Datetime\DateFormatter
*/
protected $dateFormatter;
......@@ -75,7 +75,7 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
* The entity query object for feed items.
* @param \Drupal\aggregator\ItemStorageInterface $item_storage
* The entity storage for feed items.
* @param \Drupal\Core\Datetime\Date $date_formatter
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* The date formatter service.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config, QueryInterface $item_query, ItemStorageInterface $item_storage, DateFormatter $date_formatter) {
......@@ -99,7 +99,7 @@ public static function create(ContainerInterface $container, array $configuratio
$container->get('config.factory'),
$container->get('entity.query')->get('aggregator_item'),
$container->get('entity.manager')->getStorage('aggregator_item'),
$container->get('date')
$container->get('date.formatter')
);
}
......
......@@ -228,7 +228,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
// Identical options to the ones for page caching.
// @see \Drupal\system\Form\PerformanceForm::buildForm()
$period = array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400);
$period = array_map(array(\Drupal::service('date'), 'formatInterval'), array_combine($period, $period));
$period = array_map(array(\Drupal::service('date.formatter'), 'formatInterval'), array_combine($period, $period));
$period[0] = '<' . t('no caching') . '>';
$period[\Drupal\Core\Cache\Cache::PERMANENT] = t('Forever');
$form['cache'] = array(
......
......@@ -62,7 +62,7 @@ public function testBlockInterface() {
$definition = $display_block->getPluginDefinition();
$period = array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400);
$period = array_map(array(\Drupal::service('date'), 'formatInterval'), array_combine($period, $period));
$period = array_map(array(\Drupal::service('date.formatter'), 'formatInterval'), array_combine($period, $period));
$period[0] = '<' . t('no caching') . '>';
$period[\Drupal\Core\Cache\Cache::PERMANENT] = t('Forever');
$contexts = \Drupal::service("cache_contexts")->getLabels();
......
......@@ -10,7 +10,7 @@
use Drupal\comment\CommentInterface;
use Drupal\comment\CommentStorageInterface;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormBase;
......@@ -39,7 +39,7 @@ class CommentAdminOverview extends FormBase {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\Date
* @var \Drupal\Core\Datetime\DateFormatter
*/
protected $dateFormatter;
......@@ -57,7 +57,7 @@ class CommentAdminOverview extends FormBase {
* The entity manager service.
* @param \Drupal\comment\CommentStorageInterface $comment_storage
* The comment storage.
* @param \Drupal\Core\Datetime\Date $date_formatter
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* The date formatter service.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
......@@ -76,7 +76,7 @@ public static function create(ContainerInterface $container) {
return new static(
$container->get('entity.manager'),
$container->get('entity.manager')->getStorage('comment'),
$container->get('date'),
$container->get('date.formatter'),
$container->get('module_handler')
);
}
......
......@@ -59,8 +59,8 @@ function testCommentTokenReplacement() {
$tests['[comment:body]'] = $comment->comment_body->processed;
$tests['[comment:url]'] = url('comment/' . $comment->id(), $url_options + array('fragment' => 'comment-' . $comment->id()));
$tests['[comment:edit-url]'] = url('comment/' . $comment->id() . '/edit', $url_options);
$tests['[comment:created:since]'] = \Drupal::service('date')->formatInterval(REQUEST_TIME - $comment->getCreatedTime(), 2, $language_interface->id);
$tests['[comment:changed:since]'] = \Drupal::service('date')->formatInterval(REQUEST_TIME - $comment->getChangedTime(), 2, $language_interface->id);
$tests['[comment:created:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $comment->getCreatedTime(), 2, $language_interface->id);
$tests['[comment:changed:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $comment->getChangedTime(), 2, $language_interface->id);
$tests['[comment:parent:cid]'] = $comment->hasParentComment() ? $comment->getParentComment()->id() : NULL;
$tests['[comment:parent:title]'] = String::checkPlain($parent_comment->getSubject());
$tests['[comment:node:nid]'] = $comment->getCommentedEntityId();
......
......@@ -26,7 +26,7 @@ class DateFormat implements ElementInterface {
*/
public function getFormElement(DataDefinitionInterface $definition, LanguageInterface $language, $value) {
$description = $this->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'));
$format = $this->t('Displayed as %date_format', array('%date_format' => \Drupal::service('date')->format(REQUEST_TIME, 'custom', $value)));
$format = $this->t('Displayed as %date_format', array('%date_format' => \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', $value)));
return array(
'#type' => 'textfield',
'#title' => $this->t($definition->getLabel()) . '<span class="visually-hidden"> (' . $language->name . ')</span>',
......@@ -63,7 +63,7 @@ public static function ajaxSample(array $form, FormStateInterface $form_state) {
// Format the date with a custom date format with the given pattern.
// The object is not instantiated in an Ajax context, so $this->t()
// cannot be used here.
$format = t('Displayed as %date_format', array('%date_format' => \Drupal::service('date')->format(REQUEST_TIME, 'custom', $format_value)));
$format = t('Displayed as %date_format', array('%date_format' => \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', $format_value)));
// Return a command instead of a string, since the Ajax framework
// automatically prepends an additional empty DIV element for a string,
......
......@@ -8,7 +8,7 @@
namespace Drupal\contact\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Flood\FloodInterface;
use Drupal\contact\CategoryInterface;
use Drupal\user\UserInterface;
......@@ -32,7 +32,7 @@ class ContactController extends ControllerBase {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\Date
* @var \Drupal\Core\Datetime\DateFormatter
*/
protected $dateFormatter;
......@@ -41,7 +41,7 @@ class ContactController extends ControllerBase {
*
* @param \Drupal\Core\Flood\FloodInterface $flood
* The flood service.
* @param \Drupal\Core\Datetime\Date $date_formatter
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* The date service.
*/
public function __construct(FloodInterface $flood, DateFormatter $date_formatter) {
......@@ -55,7 +55,7 @@ public function __construct(FloodInterface $flood, DateFormatter $date_formatter
public static function create(ContainerInterface $container) {
return new static(
$container->get('flood'),
$container->get('date')
$container->get('date.formatter')
);
}
......
......@@ -209,7 +209,7 @@ function testPersonalContactFlood() {
// Submit contact form one over limit.
$this->drupalGet('user/' . $this->contact_user->id(). '/contact');
$this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => $flood_limit, '@interval' => \Drupal::service('date')->formatInterval(\Drupal::config('contact.settings')->get('flood.interval')))), 'Normal user denied access to flooded contact form.');
$this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => $flood_limit, '@interval' => \Drupal::service('date.formatter')->formatInterval(\Drupal::config('contact.settings')->get('flood.interval')))), 'Normal user denied access to flooded contact form.');
// Test that the admin user can still access the contact form even though
// the flood limit was reached.
......
......@@ -212,7 +212,7 @@ function testSiteWideContact() {
// Submit contact form one over limit.
$this->drupalGet('contact');
$this->assertResponse(403);
$this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => \Drupal::config('contact.settings')->get('flood.limit'), '@interval' => \Drupal::service('date')->formatInterval(600))));
$this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => \Drupal::config('contact.settings')->get('flood.limit'), '@interval' => \Drupal::service('date.formatter')->formatInterval(600))));
// Test listing controller.
$this->drupalLogin($admin_user);
......
......@@ -7,7 +7,7 @@
namespace Drupal\datetime\Plugin\Field\FieldFormatter;
use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
......@@ -42,7 +42,7 @@ public static function defaultSettings() {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\Date
* @var \Drupal\Core\Datetime\DateFormatter
*/
protected $dateFormatter;
......@@ -70,7 +70,7 @@ public static function defaultSettings() {
* The view mode.
* @param array $third_party_settings
* Third party settings.
* @param \Drupal\Core\Datetime\Date $date_formatter
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* The date formatter service.
* @param \Drupal\Core\Entity\EntityStorageInterface $date_storage
* The date storage.
......@@ -94,7 +94,7 @@ public static function create(ContainerInterface $container, array $configuratio
$configuration['label'],
$configuration['view_mode'],
$configuration['third_party_settings'],
$container->get('date'),
$container->get('date.formatter'),
$container->get('entity.manager')->getStorage('date_format')
);
}
......
......@@ -12,7 +12,7 @@
use Drupal\Component\Utility\Xss;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Database\Connection;
use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormBuilderInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -39,7 +39,7 @@ class DbLogController extends ControllerBase {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\Date
* @var \Drupal\Core\Datetime\DateFormatter
*/
protected $dateFormatter;
......@@ -57,7 +57,7 @@ public static function create(ContainerInterface $container) {
return new static(
$container->get('database'),
$container->get('module_handler'),
$container->get('date'),
$container->get('date.formatter'),
$container->get('form_builder')
);
}
......@@ -69,7 +69,7 @@ public static function create(ContainerInterface $container) {
* A database connection.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* A module handler.
* @param \Drupal\Core\Datetime\Date $date_formatter
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* The date formatter service.
* @param \Drupal\Core\Form\FormBuilderInterface $form_builder
* The form builder service.
......
......@@ -735,5 +735,5 @@ function template_preprocess_forum_submitted(&$variables) {
$username = array('#theme' => 'username', '#account' => user_load($variables['topic']->uid));
$variables['author'] = drupal_render($username);
}
$variables['time'] = isset($variables['topic']->created) ? \Drupal::service('date')->formatInterval(REQUEST_TIME - $variables['topic']->created) : '';
$variables['time'] = isset($variables['topic']->created) ? \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $variables['topic']->created) : '';
}
......@@ -156,6 +156,6 @@ function template_preprocess_locale_translation_update_info(&$variables) {
function template_preprocess_locale_translation_last_check(&$variables) {
$last = $variables['last'];
$variables['last_checked'] = ($last != NULL);
$variables['time'] = \Drupal::service('date')->formatInterval(REQUEST_TIME - $last);
$variables['time'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $last);
$variables['link'] = l(t('Check manually'), 'admin/reports/translations/check', array('query' => drupal_get_destination()));
}
......@@ -10,7 +10,7 @@
use Drupal\Component\Utility\String;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\node\NodeTypeInterface;
use Drupal\node\NodeInterface;
......@@ -24,14 +24,14 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\Date
* @var \Drupal\Core\Datetime\DateFormatter
*/
protected $dateFormatter;
/**
* Constructs a NodeController object.
*
* @param \Drupal\Core\Datetime\Date $date_formatter
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* The date formatter service.
*/
public function __construct(DateFormatter $date_formatter) {
......@@ -42,7 +42,7 @@ public function __construct(DateFormatter $date_formatter) {
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container->get('date'));
return new static($container->get('date.formatter'));
}
......
......@@ -8,7 +8,7 @@
namespace Drupal\node;
use Drupal\Component\Utility\String;
use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Entity\EntityStorageInterface;
......@@ -26,7 +26,7 @@ class NodeListBuilder extends EntityListBuilder {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\Date
* @var \Drupal\Core\Datetime\DateFormatter
*/
protected $dateFormatter;
......@@ -37,7 +37,7 @@ class NodeListBuilder extends EntityListBuilder {
* The entity type definition.
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The entity storage class.
* @param \Drupal\Core\Datetime\Date $date_formatter
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* The date formatter service.
*/
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, DateFormatter $date_formatter) {
......@@ -53,7 +53,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('date')
$container->get('date.formatter')
);
}
......
......@@ -74,8 +74,8 @@ function testNodeTokenReplacement() {
$tests['[node:author]'] = String::checkPlain($account->getUsername());
$tests['[node:author:uid]'] = $node->getOwnerId();
$tests['[node:author:name]'] = String::checkPlain($account->getUsername());
$tests['[node:created:since]'] = \Drupal::service('date')->formatInterval(REQUEST_TIME - $node->getCreatedTime(), 2, $this->interfaceLanguage->id);
$tests['[node:changed:since]'] = \Drupal::service('date')->formatInterval(REQUEST_TIME - $node->getChangedTime(), 2, $this->interfaceLanguage->id);
$tests['[node:created:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $node->getCreatedTime(), 2, $this->interfaceLanguage->id);
$tests['[node:changed:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $node->getChangedTime(), 2, $this->interfaceLanguage->id);
// Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
......
......@@ -8,7 +8,7 @@
namespace Drupal\system;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
......@@ -24,7 +24,7 @@ class DateFormatListBuilder extends ConfigEntityListBuilder {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\Date
* @var \Drupal\Core\Datetime\DateFormatter
*/
protected $dateFormatter;
......@@ -35,7 +35,7 @@ class DateFormatListBuilder extends ConfigEntityListBuilder {
* The entity type definition.
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The entity storage class.
* @param \Drupal\Core\Datetime\Date $date_formatter
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* The date formatter service.
*/
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, DateFormatter $date_formatter) {
......@@ -51,7 +51,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('date')
$container->get('date.formatter')
);
}
......
......@@ -9,7 +9,7 @@
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\CronInterface;
use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\State\StateInterface;
use Drupal\Core\Form\ConfigFormBase;
......@@ -38,7 +38,7 @@ class CronForm extends ConfigFormBase {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\Date
* @var \Drupal\Core\Datetime\DateFormatter
*/
protected $dateFormatter;
......@@ -51,7 +51,7 @@ class CronForm extends ConfigFormBase {
* The state key value store.
* @param \Drupal\Core\CronInterface $cron
* The cron service.
* @param \Drupal\Core\Datetime\Date $date_formatter
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* The date formatter service.
*/
public function __construct(ConfigFactoryInterface $config_factory, StateInterface $state, CronInterface $cron, DateFormatter $date_formatter) {
......@@ -69,7 +69,7 @@ public static function create(ContainerInterface $container) {
$container->get('config.factory'),
$container->get('state'),
$container->get('cron'),
$container->get('date')
$container->get('date.formatter')
);
}
......
......@@ -7,7 +7,7 @@
namespace Drupal\system\Form;
use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
......@@ -21,14 +21,14 @@ class DateFormatDeleteForm extends EntityConfirmFormBase {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\Date
* @var \Drupal\Core\Datetime\DateFormatter
*/
protected $dateFormatter;
/**
* Constructs an DateFormatDeleteForm object.
*
* @param \Drupal\Core\Datetime\Date $date_formatter
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* The date formatter service.
*/
public function __construct(DateFormatter $date_formatter) {
......@@ -40,7 +40,7 @@ public function __construct(DateFormatter $date_formatter) {
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('date')
$container->get('date.formatter')
);
}
......
......@@ -10,7 +10,7 @@
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand;
use Drupal\Core\Config\Entity\ConfigEntityStorageInterface;
use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -25,7 +25,7 @@ abstract class DateFormatFormBase extends EntityForm {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\Date
* @var \Drupal\Core\Datetime\DateFormatter
*/
protected $dateFormatter;
......@@ -39,7 +39,7 @@ abstract class DateFormatFormBase extends EntityForm {
/**
* Constructs a new date format form.
*
* @param \Drupal\Core\Datetime\Date $date_formatter
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* The date service.
* @param \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $date_format_storage
* The date format storage.
......@@ -56,7 +56,7 @@ public function __construct(DateFormatter $date_formatter, ConfigEntityStorageIn
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('date'),
$container->get('date.formatter'),
$container->get('entity.manager')->getStorage('date_format')
);
}
......@@ -93,7 +93,7 @@ public function exists($entity_id, array $element) {
public static function dateTimeLookup(array $form, FormStateInterface $form_state) {
$format = '';
if (!empty($form_state['values']['date_format_pattern'])) {
$format = t('Displayed as %date_format', array('%date_format' => \Drupal::service('date')->format(REQUEST_TIME, 'custom', $form_state['values']['date_format_pattern'])));
$format = t('Displayed as %date_format', array('%date_format' => \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', $form_state['values']['date_format_pattern'])));
}
// Return a command instead of a string, since the Ajax framework
// automatically prepends an additional empty DIV element for a string, which
......
......@@ -9,7 +9,7 @@
use Drupal\Component\Utility\String;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StreamWrapper\PublicStream;
use Drupal\Core\Form\ConfigFormBase;
......@@ -23,7 +23,7 @@ class FileSystemForm extends ConfigFormBase {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\Date
* @var \Drupal\Core\Datetime\DateFormatter
*/
protected $dateFormatter;
......@@ -32,7 +32,7 @@ class FileSystemForm extends ConfigFormBase {
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The factory for configuration objects.
* @param \Drupal\Core\Datetime\Date $date_formatter
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* The date formatter service.
*/
public function __construct(ConfigFactoryInterface $config_factory, DateFormatter $date_formatter) {
......@@ -46,7 +46,7 @@ public function __construct(ConfigFactoryInterface $config_factory, DateFormatte
public static function create(ContainerInterface $container) {
return new static (
$container->get('config.factory'),
$container->get('date')
$container->get('date.formatter')
);
}
......
......@@ -10,7 +10,7 @@
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Datetime\Date as DateFormatter;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -29,7 +29,7 @@ class PerformanceForm extends ConfigFormBase {
/**
* The date formatter service.
*