{"action":"created","issue":{"url":"https://api.github.com/repos/briannesbitt/Carbon/issues/1564","repository_url":"https://api.github.com/repos/briannesbitt/Carbon","labels_url":"https://api.github.com/repos/briannesbitt/Carbon/issues/1564/labels{/name}","comments_url":"https://api.github.com/repos/briannesbitt/Carbon/issues/1564/comments","events_url":"https://api.github.com/repos/briannesbitt/Carbon/issues/1564/events","html_url":"https://github.com/briannesbitt/Carbon/issues/1564","id":394579974,"node_id":"MDU6SXNzdWUzOTQ1Nzk5NzQ=","number":1564,"title":"utcOffset(0) incorrect year","user":{"login":"wangchj","id":1118410,"node_id":"MDQ6VXNlcjExMTg0MTA=","avatar_url":"https://avatars1.githubusercontent.com/u/1118410?v=4","gravatar_id":"","url":"https://api.github.com/users/wangchj","html_url":"https://github.com/wangchj","followers_url":"https://api.github.com/users/wangchj/followers","following_url":"https://api.github.com/users/wangchj/following{/other_user}","gists_url":"https://api.github.com/users/wangchj/gists{/gist_id}","starred_url":"https://api.github.com/users/wangchj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wangchj/subscriptions","organizations_url":"https://api.github.com/users/wangchj/orgs","repos_url":"https://api.github.com/users/wangchj/repos","events_url":"https://api.github.com/users/wangchj/events{/privacy}","received_events_url":"https://api.github.com/users/wangchj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-12-28T08:30:29Z","updated_at":"2018-12-28T11:05:16Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"The following assertion fails\r\n\r\n```php\r\npublic function testUtcOffset() {\r\n    $carbon = Carbon::createFromTimestampUTC(0)->utcOffset(0);\r\n    $this->assertSame(1970, $carbon->year);\r\n}\r\n```\r\n\r\n```\r\nTest  tests/unit/dependencies/CarbonTest.php:testUtcOffset\r\nFailed asserting that 1969 is identical to 1970.\r\n```\r\n\r\nCarbon version: 2.9.1\r\nPHP version: 7.1.16\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/briannesbitt/Carbon/issues/comments/450342040","html_url":"https://github.com/briannesbitt/Carbon/issues/1564#issuecomment-450342040","issue_url":"https://api.github.com/repos/briannesbitt/Carbon/issues/1564","id":450342040,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MDM0MjA0MA==","user":{"login":"kylekatarnls","id":5966783,"node_id":"MDQ6VXNlcjU5NjY3ODM=","avatar_url":"https://avatars1.githubusercontent.com/u/5966783?v=4","gravatar_id":"","url":"https://api.github.com/users/kylekatarnls","html_url":"https://github.com/kylekatarnls","followers_url":"https://api.github.com/users/kylekatarnls/followers","following_url":"https://api.github.com/users/kylekatarnls/following{/other_user}","gists_url":"https://api.github.com/users/kylekatarnls/gists{/gist_id}","starred_url":"https://api.github.com/users/kylekatarnls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kylekatarnls/subscriptions","organizations_url":"https://api.github.com/users/kylekatarnls/orgs","repos_url":"https://api.github.com/users/kylekatarnls/repos","events_url":"https://api.github.com/users/kylekatarnls/events{/privacy}","received_events_url":"https://api.github.com/users/kylekatarnls/received_events","type":"User","site_admin":false},"created_at":"2018-12-28T11:05:16Z","updated_at":"2018-12-28T11:05:16Z","author_association":"COLLABORATOR","body":"The user's perspective can change (I can travel) but the event moment does not change, that's why moments should be saved in an agnostic way (UTC date-time) and the user timezone to use to display this date should be stored in a dedicated place (not with dates themselves but with users/contexts) it will also avoid duplicate data (saving a timezone/offset for 99+ dates related to a user, instead of 1 time for the user only).\r\n\r\nWe can imagine to fix timezone to get a more accurate offset but internally PHP will handle a timezone (not an offset) and so if you change the date and fall in a different DST time, the offset will be lost again.\r\n\r\nSo instead of working around PHP internal system. I recommend to store all dates in UTC, and set a named timezone on display, it's the right thing to do. Handling offset or saving dates in anything else than UTC is a weak pattern that always lead to issues as soon as the user travel. You may think you're on a particular case that would require to handle things differently, but believe me, you're more likely in this very common situation: wanting to store precise moments and display them to the user in its own timezone, and this situation does not require to modify/save offset for each date."}}
{"actor":{"display_login":"kylekatarnls"}}