diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php index a05f7e70a876a3fc341e55cab971735838c26a97..f220d1a31484ec01c5e295d6774f24fa344996d1 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php @@ -485,7 +485,7 @@ public function testDateFormatTranslation() { // Formatting the date 8 / 27 / 1985 @ 13:37 EST with pattern D should // display "Tue". - $formatted_date = format_date(494015820, $id, NULL, NULL, 'fr'); + $formatted_date = format_date(494015820, $id, NULL, 'America/New_York', 'fr'); $this->assertEqual($formatted_date, 'Tue', 'Got the right formatted date using the date format translation pattern.'); } } diff --git a/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php b/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php index 39fcccd80b6ab710615657a2fcf28ce72d670bf0..588e779f2f800049e0233a58fc9d9d9eb15e0c08 100644 --- a/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php +++ b/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php @@ -117,7 +117,7 @@ public function testConfigTranslation() { // Formatting the date 8 / 27 / 1985 @ 13:37 EST with pattern D should // display "Tue". - $formatted_date = format_date(494015820, $type = 'medium', NULL, NULL, $this->langcode); + $formatted_date = format_date(494015820, $type = 'medium', NULL, 'America/New_York', $this->langcode); $this->assertEqual($formatted_date, 'Tue', 'Got the right formatted date using the date format translation pattern.'); // Assert strings from image module config are not available. diff --git a/core/modules/rdf/src/CommonDataConverter.php b/core/modules/rdf/src/CommonDataConverter.php index af95d37e307532d967ea34286fa2ea98350a7c42..ef63439350e45610ed3e9fdbda5cb2fab1c7aae5 100644 --- a/core/modules/rdf/src/CommonDataConverter.php +++ b/core/modules/rdf/src/CommonDataConverter.php @@ -34,7 +34,7 @@ public static function rawValue($data) { * Returns the ISO 8601 timestamp. */ public static function dateIso8601Value($data) { - return date_iso8601($data['value']); + return \Drupal::service('date.formatter')->format($data['value'], 'custom', 'c', 'UTC'); } } diff --git a/core/modules/rdf/src/Tests/CommentAttributesTest.php b/core/modules/rdf/src/Tests/CommentAttributesTest.php index e678de2e3750dd58c9bf644a905da6aa86c8761e..f7ad33a228b2a1b0b6171a8544f5bd3bce4f3c5e 100644 --- a/core/modules/rdf/src/Tests/CommentAttributesTest.php +++ b/core/modules/rdf/src/Tests/CommentAttributesTest.php @@ -264,14 +264,14 @@ function _testBasicCommentRdfaMarkup($graph, CommentInterface $comment, $account // Comment date. $expected_value = array( 'type' => 'literal', - 'value' => date('c', $comment->getCreatedTime()), + 'value' => format_date($comment->getCreatedTime(), 'custom', 'c', 'UTC'), 'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime', ); $this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/dc/terms/date', $expected_value), 'Comment date found in RDF output (dc:date).'); // Comment date. $expected_value = array( 'type' => 'literal', - 'value' => date('c', $comment->getCreatedTime()), + 'value' => format_date($comment->getCreatedTime(), 'custom', 'c', 'UTC'), 'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime', ); $this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/dc/terms/created', $expected_value), 'Comment date found in RDF output (dc:created).'); diff --git a/core/modules/rdf/src/Tests/StandardProfileTest.php b/core/modules/rdf/src/Tests/StandardProfileTest.php index 784bd80d07040397ad4c1c556ef1a1bb16d99624..5036c626c51f5a283a93b28d41dc94af78fbec48 100644 --- a/core/modules/rdf/src/Tests/StandardProfileTest.php +++ b/core/modules/rdf/src/Tests/StandardProfileTest.php @@ -356,7 +356,7 @@ protected function assertRdfaCommonNodeProperties($graph, NodeInterface $node, $ // Created date. $expected_value = array( 'type' => 'literal', - 'value' => date_iso8601($node->get('created')->value), + 'value' => format_date($node->get('created')->value, 'custom', 'c', 'UTC'), 'lang' => 'en', ); $this->assertTrue($graph->hasProperty($uri, 'http://schema.org/dateCreated', $expected_value), "$message_prefix created date was found (schema:dateCreated) in teaser."); @@ -445,7 +445,7 @@ protected function assertRdfaNodeCommentProperties($graph) { // Comment created date. $expected_value = array( 'type' => 'literal', - 'value' => date_iso8601($this->articleComment->get('created')->value), + 'value' => format_date($this->articleComment->get('created')->value, 'custom', 'c', 'UTC'), 'lang' => 'en', ); $this->assertTrue($graph->hasProperty($this->articleCommentUri, 'http://schema.org/dateCreated', $expected_value), 'Article comment created date was found (schema:dateCreated).'); diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index 30aa69edfeefc7b96d46fa2186c7fd00d7b153bf..b4ebe733bf180ad0f39fe648903f1c8a366b2a28 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -831,6 +831,15 @@ protected function initConfig(ContainerInterface $container) { ->set('css.preprocess', FALSE) ->set('js.preprocess', FALSE) ->save(); + + // Set an explicit time zone to not rely on the system one, which may vary + // from setup to setup. The Australia/Sydney time zone is chosen so all + // tests are run using an edge case scenario (UTC+10 and DST). This choice + // is made to prevent time zone related regressions and reduce the + // fragility of the testing system in general. + $config->getEditable('system.date') + ->set('timezone.default', 'Australia/Sydney') + ->save(); } /**