{"action":"created","comment":{"url":"https://api.github.com/repos/symfony/symfony/pulls/comments/50084763","id":50084763,"diff_hunk":"@@ -0,0 +1,77 @@\n+<?php\n+\n+/*\n+ * This file is part of the Symfony package.\n+ *\n+ * (c) Fabien Potencier <fabien@symfony.com>\n+ *\n+ * For the full copyright and license information, please view the LICENSE\n+ * file that was distributed with this source code.\n+ */\n+\n+namespace Symfony\\Component\\Serializer\\Tests\\Normalizer;\n+\n+use Symfony\\Component\\Serializer\\Normalizer\\DateTimeNormalizer;\n+\n+/**\n+ * @author Kévin Dunglas <dunglas@gmail.com>\n+ */\n+class DateTimeNormalizerTest extends \\PHPUnit_Framework_TestCase\n+{\n+    /**\n+     * @var DateTimeNormalizer\n+     */\n+    private $normalizer;\n+\n+    public function setUp()\n+    {\n+        $this->normalizer = new DateTimeNormalizer();\n+    }\n+\n+    public function testSupportNormalization()\n+    {\n+        $this->assertTrue($this->normalizer->supportsNormalization(new \\DateTime()));\n+        $this->assertTrue($this->normalizer->supportsNormalization(new \\DateTimeImmutable()));\n+        $this->assertFalse($this->normalizer->supportsNormalization(new \\stdClass()));\n+    }\n+\n+    public function testNormalize()\n+    {\n+        $this->assertEquals('2016-01-01T00:00:00+00:00', $this->normalizer->normalize(new \\DateTime('2016/01/01')));\n+        $this->assertEquals('2016-01-01T00:00:00+00:00', $this->normalizer->normalize(new \\DateTimeImmutable('2016/01/01')));\n+    }\n+\n+    public function testContextFormat()\n+    {\n+        $this->assertEquals('2016', $this->normalizer->normalize(new \\DateTime('2016/01/01'), null, array(DateTimeNormalizer::FORMAT_KEY => 'Y')));","path":"src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php","position":46,"original_position":46,"commit_id":"f49fbc3d2c7be1f770c20ca5e848a60db318fa98","original_commit_id":"f047a26069992cb5e2b2d2bdde0eb09b2c7ee27f","user":{"login":"paradajozsef","id":3610051,"avatar_url":"https://avatars.githubusercontent.com/u/3610051?v=3","gravatar_id":"","url":"https://api.github.com/users/paradajozsef","html_url":"https://github.com/paradajozsef","followers_url":"https://api.github.com/users/paradajozsef/followers","following_url":"https://api.github.com/users/paradajozsef/following{/other_user}","gists_url":"https://api.github.com/users/paradajozsef/gists{/gist_id}","starred_url":"https://api.github.com/users/paradajozsef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paradajozsef/subscriptions","organizations_url":"https://api.github.com/users/paradajozsef/orgs","repos_url":"https://api.github.com/users/paradajozsef/repos","events_url":"https://api.github.com/users/paradajozsef/events{/privacy}","received_events_url":"https://api.github.com/users/paradajozsef/received_events","type":"User","site_admin":false},"body":"You are right, ty.","created_at":"2016-01-19T08:41:51Z","updated_at":"2016-01-19T08:41:51Z","html_url":"https://github.com/symfony/symfony/pull/17411#discussion_r50084763","pull_request_url":"https://api.github.com/repos/symfony/symfony/pulls/17411","_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments/50084763"},"html":{"href":"https://github.com/symfony/symfony/pull/17411#discussion_r50084763"},"pull_request":{"href":"https://api.github.com/repos/symfony/symfony/pulls/17411"}}},"pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/17411","id":56276609,"html_url":"https://github.com/symfony/symfony/pull/17411","diff_url":"https://github.com/symfony/symfony/pull/17411.diff","patch_url":"https://github.com/symfony/symfony/pull/17411.patch","issue_url":"https://api.github.com/repos/symfony/symfony/issues/17411","number":17411,"state":"open","locked":false,"title":"[Serializer] Add a new DateTime normalizer","user":{"login":"dunglas","id":57224,"avatar_url":"https://avatars.githubusercontent.com/u/57224?v=3","gravatar_id":"","url":"https://api.github.com/users/dunglas","html_url":"https://github.com/dunglas","followers_url":"https://api.github.com/users/dunglas/followers","following_url":"https://api.github.com/users/dunglas/following{/other_user}","gists_url":"https://api.github.com/users/dunglas/gists{/gist_id}","starred_url":"https://api.github.com/users/dunglas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dunglas/subscriptions","organizations_url":"https://api.github.com/users/dunglas/orgs","repos_url":"https://api.github.com/users/dunglas/repos","events_url":"https://api.github.com/users/dunglas/events{/privacy}","received_events_url":"https://api.github.com/users/dunglas/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Bug fix?      | no\r\n| New feature?  | yes\r\n| BC breaks?    | no\r\n| Deprecations? | no\r\n| Tests pass?   | yes\r\n| Fixed tickets | n/a\r\n| License       | MIT\r\n| Doc PR        | todo\r\n\r\nThis PR add support for dates and times to the Normalizer component. It supports all date and time formats supported by PHP. Dates and times are normalized in the RFC 3339 format by default. The output format can be customized using the `$context` parameter. The default format can be changed using a constructor parameter.\r\n\r\nUsage:\r\n\r\n```php\r\nuse Symfony\\Component\\Serializer\\Normalizer\\DateTimeNormalizer;\r\nuse Symfony\\Component\\Serializer\\Serializer;\r\n\r\n$serializer = new Serializer(array(new DateTimeNormalizer()));\r\n\r\necho $serializer->normalize(new \\DateTimeImmutable('2016/01/01'));\r\n// 2016-01-01T00:00:00+00:00\r\n\r\necho $serializer->normalize(new \\DateTime('2016/01/01'));\r\n// 2016-01-01T00:00:00+00:00\r\n\r\necho $serializer->normalize(new \\DateTime('2016/01/01'), null, array(DateTimeNormalizer::FORMAT_KEY => 'Y'))\r\n// 2016\r\n\r\nvar_dump($serializer->denormalize('2016-01-01T00:00:00+00:00', \\DateTimeInterface::class));\r\n// class DateTimeImmutable#1 (3) {\r\n//   public $date =>\r\n//   string(26) \"2016-01-01 00:00:00.000000\"\r\n//   public $timezone_type =>\r\n//   int(1)\r\n//   public $timezone =>\r\n//   string(6) \"+00:00\"\r\n// }\r\n\r\nvar_dump($serializer->denormalize('2016-01-01T00:00:00+00:00', \\DateTime::class));\r\n// class DateTime#1 (3) {\r\n//   public $date =>\r\n//   string(26) \"2016-01-01 00:00:00.000000\"\r\n//   public $timezone_type =>\r\n//   int(1)\r\n//   public $timezone =>\r\n//   string(6) \"+00:00\"\r\n// }\r\n```\r\n","created_at":"2016-01-17T12:23:15Z","updated_at":"2016-01-19T08:41:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"627a93e46acd8391e59d0d6ae8093f4c612a87b3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/symfony/symfony/pulls/17411/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony/pulls/17411/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/17411/comments","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/f49fbc3d2c7be1f770c20ca5e848a60db318fa98","head":{"label":"dunglas:normalizer_datetime","ref":"normalizer_datetime","sha":"f49fbc3d2c7be1f770c20ca5e848a60db318fa98","user":{"login":"dunglas","id":57224,"avatar_url":"https://avatars.githubusercontent.com/u/57224?v=3","gravatar_id":"","url":"https://api.github.com/users/dunglas","html_url":"https://github.com/dunglas","followers_url":"https://api.github.com/users/dunglas/followers","following_url":"https://api.github.com/users/dunglas/following{/other_user}","gists_url":"https://api.github.com/users/dunglas/gists{/gist_id}","starred_url":"https://api.github.com/users/dunglas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dunglas/subscriptions","organizations_url":"https://api.github.com/users/dunglas/orgs","repos_url":"https://api.github.com/users/dunglas/repos","events_url":"https://api.github.com/users/dunglas/events{/privacy}","received_events_url":"https://api.github.com/users/dunglas/received_events","type":"User","site_admin":false},"repo":{"id":1124839,"name":"symfony","full_name":"dunglas/symfony","owner":{"login":"dunglas","id":57224,"avatar_url":"https://avatars.githubusercontent.com/u/57224?v=3","gravatar_id":"","url":"https://api.github.com/users/dunglas","html_url":"https://github.com/dunglas","followers_url":"https://api.github.com/users/dunglas/followers","following_url":"https://api.github.com/users/dunglas/following{/other_user}","gists_url":"https://api.github.com/users/dunglas/gists{/gist_id}","starred_url":"https://api.github.com/users/dunglas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dunglas/subscriptions","organizations_url":"https://api.github.com/users/dunglas/orgs","repos_url":"https://api.github.com/users/dunglas/repos","events_url":"https://api.github.com/users/dunglas/events{/privacy}","received_events_url":"https://api.github.com/users/dunglas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dunglas/symfony","description":"The Symfony2 PHP framework (PHP 5.3 only -- not yet stable) -- documentation for master is at http://docs.symfony-reloaded.org/master/","fork":true,"url":"https://api.github.com/repos/dunglas/symfony","forks_url":"https://api.github.com/repos/dunglas/symfony/forks","keys_url":"https://api.github.com/repos/dunglas/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dunglas/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dunglas/symfony/teams","hooks_url":"https://api.github.com/repos/dunglas/symfony/hooks","issue_events_url":"https://api.github.com/repos/dunglas/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/dunglas/symfony/events","assignees_url":"https://api.github.com/repos/dunglas/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/dunglas/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/dunglas/symfony/tags","blobs_url":"https://api.github.com/repos/dunglas/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dunglas/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dunglas/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/dunglas/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dunglas/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/dunglas/symfony/languages","stargazers_url":"https://api.github.com/repos/dunglas/symfony/stargazers","contributors_url":"https://api.github.com/repos/dunglas/symfony/contributors","subscribers_url":"https://api.github.com/repos/dunglas/symfony/subscribers","subscription_url":"https://api.github.com/repos/dunglas/symfony/subscription","commits_url":"https://api.github.com/repos/dunglas/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/dunglas/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/dunglas/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/dunglas/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/dunglas/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/dunglas/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dunglas/symfony/merges","archive_url":"https://api.github.com/repos/dunglas/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dunglas/symfony/downloads","issues_url":"https://api.github.com/repos/dunglas/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/dunglas/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/dunglas/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/dunglas/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dunglas/symfony/labels{/name}","releases_url":"https://api.github.com/repos/dunglas/symfony/releases{/id}","created_at":"2010-11-30T08:18:04Z","updated_at":"2014-06-03T21:19:58Z","pushed_at":"2016-01-19T08:08:19Z","git_url":"git://github.com/dunglas/symfony.git","ssh_url":"git@github.com:dunglas/symfony.git","clone_url":"https://github.com/dunglas/symfony.git","svn_url":"https://github.com/dunglas/symfony","homepage":"http://www.symfony-project.org/","size":65507,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"symfony:master","ref":"master","sha":"caae21c52ffea6ba3377c7d07b15a3c2f0a0f702","user":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"repo":{"id":458058,"name":"symfony","full_name":"symfony/symfony","owner":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/symfony/symfony","description":"The Symfony PHP framework","fork":false,"url":"https://api.github.com/repos/symfony/symfony","forks_url":"https://api.github.com/repos/symfony/symfony/forks","keys_url":"https://api.github.com/repos/symfony/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony/symfony/teams","hooks_url":"https://api.github.com/repos/symfony/symfony/hooks","issue_events_url":"https://api.github.com/repos/symfony/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/symfony/symfony/events","assignees_url":"https://api.github.com/repos/symfony/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/symfony/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/symfony/symfony/tags","blobs_url":"https://api.github.com/repos/symfony/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony/symfony/languages","stargazers_url":"https://api.github.com/repos/symfony/symfony/stargazers","contributors_url":"https://api.github.com/repos/symfony/symfony/contributors","subscribers_url":"https://api.github.com/repos/symfony/symfony/subscribers","subscription_url":"https://api.github.com/repos/symfony/symfony/subscription","commits_url":"https://api.github.com/repos/symfony/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/symfony/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony/symfony/merges","archive_url":"https://api.github.com/repos/symfony/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony/symfony/downloads","issues_url":"https://api.github.com/repos/symfony/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/symfony/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony/symfony/labels{/name}","releases_url":"https://api.github.com/repos/symfony/symfony/releases{/id}","created_at":"2010-01-04T14:21:21Z","updated_at":"2016-01-19T08:09:36Z","pushed_at":"2016-01-19T08:08:20Z","git_url":"git://github.com/symfony/symfony.git","ssh_url":"git@github.com:symfony/symfony.git","clone_url":"https://github.com/symfony/symfony.git","svn_url":"https://github.com/symfony/symfony","homepage":"symfony.com","size":98796,"stargazers_count":11539,"watchers_count":11539,"language":"PHP","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":4550,"mirror_url":null,"open_issues_count":917,"forks":4550,"open_issues":917,"watchers":11539,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/17411"},"html":{"href":"https://github.com/symfony/symfony/pull/17411"},"issue":{"href":"https://api.github.com/repos/symfony/symfony/issues/17411"},"comments":{"href":"https://api.github.com/repos/symfony/symfony/issues/17411/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony/pulls/17411/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony/pulls/17411/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony/statuses/f49fbc3d2c7be1f770c20ca5e848a60db318fa98"}}}}