[!!!][TASK] Use correct ISO8601 format 06/49906/8
authorBenjamin Serfhos <serfhos@gmail.com>
Mon, 12 Sep 2016 15:15:26 +0000 (17:15 +0200)
committerBenni Mack <benni@typo3.org>
Sat, 8 Oct 2016 18:54:25 +0000 (20:54 +0200)
DateTime::ISO8601 is not compatible with ISO-8601, but is left this
way for backward compatibility reasons. Use DateTime::ATOM or
DATE_ATOM for compatibility with ISO-8601 instead.

Resolves: #77919
Releases: master
Change-Id: Iab7217c492b4137b8cb0b6e3608e2d8071d861f6
Reviewed-on: https://review.typo3.org/49906
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Tested-by: Tomasz Stępniak <stempl88@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Documentation/Changelog/master/Breaking-77919-ChangedDateTimeISO8601ToDateTimeATOM.rst [new file with mode: 0644]
typo3/sysext/extbase/Classes/Mvc/View/JsonView.php
typo3/sysext/extbase/Tests/Unit/Mvc/View/JsonViewTest.php
typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/DateTimeConverterTest.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-77919-ChangedDateTimeISO8601ToDateTimeATOM.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-77919-ChangedDateTimeISO8601ToDateTimeATOM.rst
new file mode 100644 (file)
index 0000000..f30dc2f
--- /dev/null
@@ -0,0 +1,14 @@
+.. include:: ../../Includes.txt
+
+==============================================================
+Breaking: #77919 - Changed DateTime::ISO8601 to DateTime::ATOM
+==============================================================
+
+See :forge:`77919`
+
+Description
+===========
+
+The format DateTime::ISO8601 is not compatible with ISO-8601, but is left this way for backward compatibility reasons. The constant DateTime::ATOM or DATE_ATOM is used instead when rendering JsonViews via Extbase.
+
+See http://php.net/manual/en/class.datetime.php#datetime.constants.iso8601 for more information
index 6516887..00f482c 100644 (file)
@@ -301,7 +301,7 @@ class JsonView extends AbstractView
     protected function transformObject($object, array $configuration)
     {
         if ($object instanceof \DateTime) {
-            return $object->format(\DateTime::ISO8601);
+            return $object->format(\DateTime::ATOM);
         } else {
             $propertyNames = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getGettablePropertyNames($object);
 
index 0a92d66..caf3073 100644 (file)
@@ -141,12 +141,12 @@ class JsonViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
 
         $dateTimeObject = new \DateTime('2011-02-03T03:15:23', new \DateTimeZone('UTC'));
         $configuration = [];
-        $expected = '2011-02-03T03:15:23+0000';
+        $expected = '2011-02-03T03:15:23+00:00';
         $output[] = [$dateTimeObject, $configuration, $expected, 'DateTime object in UTC time zone could not be serialized.'];
 
         $dateTimeObject = new \DateTime('2013-08-15T15:25:30', new \DateTimeZone('America/Los_Angeles'));
         $configuration = [];
-        $expected = '2013-08-15T15:25:30-0700';
+        $expected = '2013-08-15T15:25:30-07:00';
         $output[] = [$dateTimeObject, $configuration, $expected, 'DateTime object in America/Los_Angeles time zone could not be serialized.'];
         return $output;
     }
index 7ff3868..138aea8 100644 (file)
@@ -135,7 +135,7 @@ class DateTimeConverterTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
             ['12:13', 'H:i', true],
             ['13.12.1980', 'd.m.Y', true],
             ['2005-08-15T15:52:01+00:00', null, true],
-            ['2005-08-15T15:52:01+0000', \DateTime::ISO8601, true],
+            ['2005-08-15T15:52:01+00:00', \DateTime::ATOM, true],
             ['1308174051', 'U', true],
         ];
     }
@@ -378,7 +378,7 @@ class DateTimeConverterTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
             [['date' => '12:13', 'dateFormat' => 'H:i'], true],
             [['date' => '13.12.1980', 'dateFormat' => 'd.m.Y'], true],
             [['date' => '2005-08-15T15:52:01+00:00', 'dateFormat' => ''], true],
-            [['date' => '2005-08-15T15:52:01+0000', 'dateFormat' => \DateTime::ISO8601], true],
+            [['date' => '2005-08-15T15:52:01+00:00', 'dateFormat' => \DateTime::ATOM], true],
             [['date' => '1308174051', 'dateFormat' => 'U'], true],
             [['date' => 1308174051, 'dateFormat' => 'U'], true],
         ];