{"action":"created","comment":{"url":"https://api.github.com/repos/elixir-lang/elixir/pulls/comments/167409944","pull_request_review_id":95632367,"id":167409944,"diff_hunk":"@@ -254,6 +256,12 @@ defmodule Date do\n     end\n   end\n \n+  def from_iso8601(<<?-, next, rest::binary>>, calendar) when next != ?- do\n+    with {:ok, %{year: year} = date} <- from_iso8601(<<next>> <> rest, calendar) do","path":"lib/elixir/lib/calendar/date.ex","position":14,"original_position":14,"commit_id":"f711b51f1a5edc6bb16b715c78c541ba4bd3e4c5","original_commit_id":"f711b51f1a5edc6bb16b715c78c541ba4bd3e4c5","user":{"login":"michalmuskala","id":477062,"avatar_url":"https://avatars0.githubusercontent.com/u/477062?v=4","gravatar_id":"","url":"https://api.github.com/users/michalmuskala","html_url":"https://github.com/michalmuskala","followers_url":"https://api.github.com/users/michalmuskala/followers","following_url":"https://api.github.com/users/michalmuskala/following{/other_user}","gists_url":"https://api.github.com/users/michalmuskala/gists{/gist_id}","starred_url":"https://api.github.com/users/michalmuskala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michalmuskala/subscriptions","organizations_url":"https://api.github.com/users/michalmuskala/orgs","repos_url":"https://api.github.com/users/michalmuskala/repos","events_url":"https://api.github.com/users/michalmuskala/events{/privacy}","received_events_url":"https://api.github.com/users/michalmuskala/received_events","type":"User","site_admin":false},"body":"I think we should extract the parsing to a separate function - right now we'll always do an allocation with the \"next\" bit.\r\n\r\n```elixir\r\ndef from_iso8601(<<?-, rest::binary>>, calendar) do\r\n  case parse_iso8601(rest) do\r\n    {year, month, day} -> \r\n      with {:ok, date} <- new(- year, month, day, Calendar.ISO), do: convert(date, calendar)\r\n\r\n    _ -> {:error, :invalid_format}\r\n  end\r\nend\r\n\r\ndef from_iso8601(string, calendar) do\r\n  case parse_iso8601(rest) do\r\n    {year, month, day} -> \r\n      with {:ok, date} <- new(year, month, day, Calendar.ISO), do: convert(date, calendar)\r\n\r\n    _ -> {:error, :invalid_format}\r\n  end\r\nend\r\n\r\n@compile {:inline, parse_iso8601: 1}\r\ndefp parse_iso8601(<<year::4-bytes, ?-, month::2-bytes, ?-, day::2-bytes>>) do\r\n  with {year, \"\"} when year > 0 <- Integer.parse(year),\r\n       {month, \"\"} <- Integer.parse(month),\r\n       {day, \"\"} <- Integer.parse(day) do\r\n    {year, month, day}\r\n   end\r\nend\r\n```","created_at":"2018-02-10T20:20:52Z","updated_at":"2018-02-10T20:20:52Z","html_url":"https://github.com/elixir-lang/elixir/pull/6638#discussion_r167409944","pull_request_url":"https://api.github.com/repos/elixir-lang/elixir/pulls/6638","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/elixir-lang/elixir/pulls/comments/167409944"},"html":{"href":"https://github.com/elixir-lang/elixir/pull/6638#discussion_r167409944"},"pull_request":{"href":"https://api.github.com/repos/elixir-lang/elixir/pulls/6638"}}},"pull_request":{"url":"https://api.github.com/repos/elixir-lang/elixir/pulls/6638","id":145286497,"html_url":"https://github.com/elixir-lang/elixir/pull/6638","diff_url":"https://github.com/elixir-lang/elixir/pull/6638.diff","patch_url":"https://github.com/elixir-lang/elixir/pull/6638.patch","issue_url":"https://api.github.com/repos/elixir-lang/elixir/issues/6638","number":6638,"state":"open","locked":false,"title":"Support negative dates in Calendar","user":{"login":"lexmag","id":248290,"avatar_url":"https://avatars2.githubusercontent.com/u/248290?v=4","gravatar_id":"","url":"https://api.github.com/users/lexmag","html_url":"https://github.com/lexmag","followers_url":"https://api.github.com/users/lexmag/followers","following_url":"https://api.github.com/users/lexmag/following{/other_user}","gists_url":"https://api.github.com/users/lexmag/gists{/gist_id}","starred_url":"https://api.github.com/users/lexmag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lexmag/subscriptions","organizations_url":"https://api.github.com/users/lexmag/orgs","repos_url":"https://api.github.com/users/lexmag/repos","events_url":"https://api.github.com/users/lexmag/events{/privacy}","received_events_url":"https://api.github.com/users/lexmag/received_events","type":"User","site_admin":false},"body":"Closes #6294.","created_at":"2017-10-07T10:41:34Z","updated_at":"2018-02-10T20:20:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2a7312b636c971c7d5953f6629777587deeafff5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/elixir-lang/elixir/pulls/6638/commits","review_comments_url":"https://api.github.com/repos/elixir-lang/elixir/pulls/6638/comments","review_comment_url":"https://api.github.com/repos/elixir-lang/elixir/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elixir-lang/elixir/issues/6638/comments","statuses_url":"https://api.github.com/repos/elixir-lang/elixir/statuses/f711b51f1a5edc6bb16b715c78c541ba4bd3e4c5","head":{"label":"lexmag:am/negative-calendar","ref":"am/negative-calendar","sha":"f711b51f1a5edc6bb16b715c78c541ba4bd3e4c5","user":{"login":"lexmag","id":248290,"avatar_url":"https://avatars2.githubusercontent.com/u/248290?v=4","gravatar_id":"","url":"https://api.github.com/users/lexmag","html_url":"https://github.com/lexmag","followers_url":"https://api.github.com/users/lexmag/followers","following_url":"https://api.github.com/users/lexmag/following{/other_user}","gists_url":"https://api.github.com/users/lexmag/gists{/gist_id}","starred_url":"https://api.github.com/users/lexmag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lexmag/subscriptions","organizations_url":"https://api.github.com/users/lexmag/orgs","repos_url":"https://api.github.com/users/lexmag/repos","events_url":"https://api.github.com/users/lexmag/events{/privacy}","received_events_url":"https://api.github.com/users/lexmag/received_events","type":"User","site_admin":false},"repo":{"id":19643959,"name":"elixir","full_name":"lexmag/elixir","owner":{"login":"lexmag","id":248290,"avatar_url":"https://avatars2.githubusercontent.com/u/248290?v=4","gravatar_id":"","url":"https://api.github.com/users/lexmag","html_url":"https://github.com/lexmag","followers_url":"https://api.github.com/users/lexmag/followers","following_url":"https://api.github.com/users/lexmag/following{/other_user}","gists_url":"https://api.github.com/users/lexmag/gists{/gist_id}","starred_url":"https://api.github.com/users/lexmag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lexmag/subscriptions","organizations_url":"https://api.github.com/users/lexmag/orgs","repos_url":"https://api.github.com/users/lexmag/repos","events_url":"https://api.github.com/users/lexmag/events{/privacy}","received_events_url":"https://api.github.com/users/lexmag/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lexmag/elixir","description":"Elixir is a functional, meta-programming aware language built on top of the Erlang VM. It is a dynamic language that focuses on tooling to leverage Erlang's abilities to build concurrent, distributed and fault-tolerant applications with hot code upgrades","fork":true,"url":"https://api.github.com/repos/lexmag/elixir","forks_url":"https://api.github.com/repos/lexmag/elixir/forks","keys_url":"https://api.github.com/repos/lexmag/elixir/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lexmag/elixir/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lexmag/elixir/teams","hooks_url":"https://api.github.com/repos/lexmag/elixir/hooks","issue_events_url":"https://api.github.com/repos/lexmag/elixir/issues/events{/number}","events_url":"https://api.github.com/repos/lexmag/elixir/events","assignees_url":"https://api.github.com/repos/lexmag/elixir/assignees{/user}","branches_url":"https://api.github.com/repos/lexmag/elixir/branches{/branch}","tags_url":"https://api.github.com/repos/lexmag/elixir/tags","blobs_url":"https://api.github.com/repos/lexmag/elixir/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lexmag/elixir/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lexmag/elixir/git/refs{/sha}","trees_url":"https://api.github.com/repos/lexmag/elixir/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lexmag/elixir/statuses/{sha}","languages_url":"https://api.github.com/repos/lexmag/elixir/languages","stargazers_url":"https://api.github.com/repos/lexmag/elixir/stargazers","contributors_url":"https://api.github.com/repos/lexmag/elixir/contributors","subscribers_url":"https://api.github.com/repos/lexmag/elixir/subscribers","subscription_url":"https://api.github.com/repos/lexmag/elixir/subscription","commits_url":"https://api.github.com/repos/lexmag/elixir/commits{/sha}","git_commits_url":"https://api.github.com/repos/lexmag/elixir/git/commits{/sha}","comments_url":"https://api.github.com/repos/lexmag/elixir/comments{/number}","issue_comment_url":"https://api.github.com/repos/lexmag/elixir/issues/comments{/number}","contents_url":"https://api.github.com/repos/lexmag/elixir/contents/{+path}","compare_url":"https://api.github.com/repos/lexmag/elixir/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lexmag/elixir/merges","archive_url":"https://api.github.com/repos/lexmag/elixir/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lexmag/elixir/downloads","issues_url":"https://api.github.com/repos/lexmag/elixir/issues{/number}","pulls_url":"https://api.github.com/repos/lexmag/elixir/pulls{/number}","milestones_url":"https://api.github.com/repos/lexmag/elixir/milestones{/number}","notifications_url":"https://api.github.com/repos/lexmag/elixir/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lexmag/elixir/labels{/name}","releases_url":"https://api.github.com/repos/lexmag/elixir/releases{/id}","deployments_url":"https://api.github.com/repos/lexmag/elixir/deployments","created_at":"2014-05-10T14:57:40Z","updated_at":"2016-01-11T21:28:07Z","pushed_at":"2018-02-10T19:45:00Z","git_url":"git://github.com/lexmag/elixir.git","ssh_url":"git@github.com:lexmag/elixir.git","clone_url":"https://github.com/lexmag/elixir.git","svn_url":"https://github.com/lexmag/elixir","homepage":"http://elixir-lang.org/","size":34260,"stargazers_count":0,"watchers_count":0,"language":"Elixir","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"elixir-lang:master","ref":"master","sha":"ff5594332ab92257452b41b1ccf9da74eed21c85","user":{"login":"elixir-lang","id":1481354,"avatar_url":"https://avatars1.githubusercontent.com/u/1481354?v=4","gravatar_id":"","url":"https://api.github.com/users/elixir-lang","html_url":"https://github.com/elixir-lang","followers_url":"https://api.github.com/users/elixir-lang/followers","following_url":"https://api.github.com/users/elixir-lang/following{/other_user}","gists_url":"https://api.github.com/users/elixir-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/elixir-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elixir-lang/subscriptions","organizations_url":"https://api.github.com/users/elixir-lang/orgs","repos_url":"https://api.github.com/users/elixir-lang/repos","events_url":"https://api.github.com/users/elixir-lang/events{/privacy}","received_events_url":"https://api.github.com/users/elixir-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":1234714,"name":"elixir","full_name":"elixir-lang/elixir","owner":{"login":"elixir-lang","id":1481354,"avatar_url":"https://avatars1.githubusercontent.com/u/1481354?v=4","gravatar_id":"","url":"https://api.github.com/users/elixir-lang","html_url":"https://github.com/elixir-lang","followers_url":"https://api.github.com/users/elixir-lang/followers","following_url":"https://api.github.com/users/elixir-lang/following{/other_user}","gists_url":"https://api.github.com/users/elixir-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/elixir-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elixir-lang/subscriptions","organizations_url":"https://api.github.com/users/elixir-lang/orgs","repos_url":"https://api.github.com/users/elixir-lang/repos","events_url":"https://api.github.com/users/elixir-lang/events{/privacy}","received_events_url":"https://api.github.com/users/elixir-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elixir-lang/elixir","description":"Elixir is a dynamic, functional language designed for building scalable and maintainable applications","fork":false,"url":"https://api.github.com/repos/elixir-lang/elixir","forks_url":"https://api.github.com/repos/elixir-lang/elixir/forks","keys_url":"https://api.github.com/repos/elixir-lang/elixir/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elixir-lang/elixir/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elixir-lang/elixir/teams","hooks_url":"https://api.github.com/repos/elixir-lang/elixir/hooks","issue_events_url":"https://api.github.com/repos/elixir-lang/elixir/issues/events{/number}","events_url":"https://api.github.com/repos/elixir-lang/elixir/events","assignees_url":"https://api.github.com/repos/elixir-lang/elixir/assignees{/user}","branches_url":"https://api.github.com/repos/elixir-lang/elixir/branches{/branch}","tags_url":"https://api.github.com/repos/elixir-lang/elixir/tags","blobs_url":"https://api.github.com/repos/elixir-lang/elixir/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elixir-lang/elixir/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elixir-lang/elixir/git/refs{/sha}","trees_url":"https://api.github.com/repos/elixir-lang/elixir/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elixir-lang/elixir/statuses/{sha}","languages_url":"https://api.github.com/repos/elixir-lang/elixir/languages","stargazers_url":"https://api.github.com/repos/elixir-lang/elixir/stargazers","contributors_url":"https://api.github.com/repos/elixir-lang/elixir/contributors","subscribers_url":"https://api.github.com/repos/elixir-lang/elixir/subscribers","subscription_url":"https://api.github.com/repos/elixir-lang/elixir/subscription","commits_url":"https://api.github.com/repos/elixir-lang/elixir/commits{/sha}","git_commits_url":"https://api.github.com/repos/elixir-lang/elixir/git/commits{/sha}","comments_url":"https://api.github.com/repos/elixir-lang/elixir/comments{/number}","issue_comment_url":"https://api.github.com/repos/elixir-lang/elixir/issues/comments{/number}","contents_url":"https://api.github.com/repos/elixir-lang/elixir/contents/{+path}","compare_url":"https://api.github.com/repos/elixir-lang/elixir/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elixir-lang/elixir/merges","archive_url":"https://api.github.com/repos/elixir-lang/elixir/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elixir-lang/elixir/downloads","issues_url":"https://api.github.com/repos/elixir-lang/elixir/issues{/number}","pulls_url":"https://api.github.com/repos/elixir-lang/elixir/pulls{/number}","milestones_url":"https://api.github.com/repos/elixir-lang/elixir/milestones{/number}","notifications_url":"https://api.github.com/repos/elixir-lang/elixir/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elixir-lang/elixir/labels{/name}","releases_url":"https://api.github.com/repos/elixir-lang/elixir/releases{/id}","deployments_url":"https://api.github.com/repos/elixir-lang/elixir/deployments","created_at":"2011-01-09T08:43:57Z","updated_at":"2018-02-10T17:21:54Z","pushed_at":"2018-02-10T20:13:56Z","git_url":"git://github.com/elixir-lang/elixir.git","ssh_url":"git@github.com:elixir-lang/elixir.git","clone_url":"https://github.com/elixir-lang/elixir.git","svn_url":"https://github.com/elixir-lang/elixir","homepage":"http://elixir-lang.org/","size":35043,"stargazers_count":12229,"watchers_count":12229,"language":"Elixir","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1770,"mirror_url":null,"archived":false,"open_issues_count":25,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":1770,"open_issues":25,"watchers":12229,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elixir-lang/elixir/pulls/6638"},"html":{"href":"https://github.com/elixir-lang/elixir/pull/6638"},"issue":{"href":"https://api.github.com/repos/elixir-lang/elixir/issues/6638"},"comments":{"href":"https://api.github.com/repos/elixir-lang/elixir/issues/6638/comments"},"review_comments":{"href":"https://api.github.com/repos/elixir-lang/elixir/pulls/6638/comments"},"review_comment":{"href":"https://api.github.com/repos/elixir-lang/elixir/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elixir-lang/elixir/pulls/6638/commits"},"statuses":{"href":"https://api.github.com/repos/elixir-lang/elixir/statuses/f711b51f1a5edc6bb16b715c78c541ba4bd3e4c5"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"michalmuskala"}}