{"action":"created","comment":{"url":"https://api.github.com/repos/rails/rails/pulls/comments/36741728","id":36741728,"diff_hunk":"@@ -90,12 +90,17 @@ module DateHelper\n       #   distance_of_time_in_words(from_time, from_time + 50.minutes, scope: 'datetime.distance_in_words.short') # => \"an hour\"\n       #   distance_of_time_in_words(from_time, from_time + 3.hours, scope: 'datetime.distance_in_words.short')    # => \"3 hours\"\n       def distance_of_time_in_words(from_time, to_time = 0, options = {})\n+        if [from_time, to_time].any?(&:nil?)\n+          raise ArgumentError, \"given time must not be nil\"\n+        end\n+\n         options = {\n           scope: :'datetime.distance_in_words'\n         }.merge!(options)\n \n         from_time = from_time.to_time if from_time.respond_to?(:to_time)\n         to_time = to_time.to_time if to_time.respond_to?(:to_time)\n+        from_time, to_time = Time.at(from_time), Time.at(to_time)","path":"actionview/lib/action_view/helpers/date_helper.rb","position":14,"original_position":14,"commit_id":"2d9f54339cc8a45954e53af0d3085d7eb7ddfb3a","original_commit_id":"2d9f54339cc8a45954e53af0d3085d7eb7ddfb3a","user":{"login":"iamvery","id":79619,"avatar_url":"https://avatars.githubusercontent.com/u/79619?v=3","gravatar_id":"","url":"https://api.github.com/users/iamvery","html_url":"https://github.com/iamvery","followers_url":"https://api.github.com/users/iamvery/followers","following_url":"https://api.github.com/users/iamvery/following{/other_user}","gists_url":"https://api.github.com/users/iamvery/gists{/gist_id}","starred_url":"https://api.github.com/users/iamvery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iamvery/subscriptions","organizations_url":"https://api.github.com/users/iamvery/orgs","repos_url":"https://api.github.com/users/iamvery/repos","events_url":"https://api.github.com/users/iamvery/events{/privacy}","received_events_url":"https://api.github.com/users/iamvery/received_events","type":"User","site_admin":false},"body":"Very interesting idea! Would there be any concern that the Time conversion of Numeric values is always in local time? Is that confusing*?\r\n\r\n* time is always so confusing :disappointed:","created_at":"2015-08-11T13:05:54Z","updated_at":"2015-08-11T13:05:54Z","html_url":"https://github.com/rails/rails/pull/20701#discussion_r36741728","pull_request_url":"https://api.github.com/repos/rails/rails/pulls/20701","_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/36741728"},"html":{"href":"https://github.com/rails/rails/pull/20701#discussion_r36741728"},"pull_request":{"href":"https://api.github.com/repos/rails/rails/pulls/20701"}}},"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/20701","id":38603577,"html_url":"https://github.com/rails/rails/pull/20701","diff_url":"https://github.com/rails/rails/pull/20701.diff","patch_url":"https://github.com/rails/rails/pull/20701.patch","issue_url":"https://api.github.com/repos/rails/rails/issues/20701","number":20701,"state":"open","locked":false,"title":"Ensure input to distance_of_time_in_words is not nil","user":{"login":"iamvery","id":79619,"avatar_url":"https://avatars.githubusercontent.com/u/79619?v=3","gravatar_id":"","url":"https://api.github.com/users/iamvery","html_url":"https://github.com/iamvery","followers_url":"https://api.github.com/users/iamvery/followers","following_url":"https://api.github.com/users/iamvery/following{/other_user}","gists_url":"https://api.github.com/users/iamvery/gists{/gist_id}","starred_url":"https://api.github.com/users/iamvery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iamvery/subscriptions","organizations_url":"https://api.github.com/users/iamvery/orgs","repos_url":"https://api.github.com/users/iamvery/repos","events_url":"https://api.github.com/users/iamvery/events{/privacy}","received_events_url":"https://api.github.com/users/iamvery/received_events","type":"User","site_admin":false},"body":"## Problem\r\n\r\nThe error message for bad input to the `distance_of_time_in_words` and related methods is cryptic. For example, if `nil` is provided as an argument to `time_ago_in_words`, this is the error:\r\n\r\n```ruby\r\nirb> helper.time_ago_in_words(nil)\r\nNoMethodError: undefined method `>' for nil:NilClass\r\n```\r\n\r\nI believe a more palatable result in this case would be to raise an `ArgumentError` for invalid input.\r\n\r\n## (Proposed) Solution\r\n\r\nThe provided implementation is a bit naive in that it only checks for `nil` arguments. While investigating the problem, I realized there are several different ways in which the input may be \"bad\".\r\n\r\n1. Argument is `nil`\r\n2. The `from_time` and `to_time` arguments are incompatible with one another. e.g.\r\n  ```ruby\r\n  irb> helper.distance_of_time_in_words(Date.current, 0)\r\n  ArgumentError: comparison of Time with 0 failed\r\n\r\n  ```\r\n3. moar?\r\n\r\nGenerally it seems like the interface requires either two numeric arguments, or two `to_time` convertible arguments.\r\n\r\nTo that end, it felt like this issue may benefit from the input of parties more familiar with the code. I would be honored and willing to help with the solution. If I am able to come up with a more \"elegant\" solution to the type situation, I will gladly post it back here.\r\n\r\nThank you! :dizzy:\r\n\r\n---\r\n\r\n### TODO\r\n- [ ] settle on solution\r\n- [ ] update docs (if needed)\r\n- [ ] update changelog","created_at":"2015-06-25T23:13:58Z","updated_at":"2015-08-11T13:05:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ae62e390cd02340515405bf098c11c4329d3b833","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rails/rails/pulls/20701/commits","review_comments_url":"https://api.github.com/repos/rails/rails/pulls/20701/comments","review_comment_url":"https://api.github.com/repos/rails/rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails/rails/issues/20701/comments","statuses_url":"https://api.github.com/repos/rails/rails/statuses/2d9f54339cc8a45954e53af0d3085d7eb7ddfb3a","head":{"label":"iamvery:date-helper-argument-error","ref":"date-helper-argument-error","sha":"2d9f54339cc8a45954e53af0d3085d7eb7ddfb3a","user":{"login":"iamvery","id":79619,"avatar_url":"https://avatars.githubusercontent.com/u/79619?v=3","gravatar_id":"","url":"https://api.github.com/users/iamvery","html_url":"https://github.com/iamvery","followers_url":"https://api.github.com/users/iamvery/followers","following_url":"https://api.github.com/users/iamvery/following{/other_user}","gists_url":"https://api.github.com/users/iamvery/gists{/gist_id}","starred_url":"https://api.github.com/users/iamvery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iamvery/subscriptions","organizations_url":"https://api.github.com/users/iamvery/orgs","repos_url":"https://api.github.com/users/iamvery/repos","events_url":"https://api.github.com/users/iamvery/events{/privacy}","received_events_url":"https://api.github.com/users/iamvery/received_events","type":"User","site_admin":false},"repo":{"id":7154568,"name":"rails","full_name":"iamvery/rails","owner":{"login":"iamvery","id":79619,"avatar_url":"https://avatars.githubusercontent.com/u/79619?v=3","gravatar_id":"","url":"https://api.github.com/users/iamvery","html_url":"https://github.com/iamvery","followers_url":"https://api.github.com/users/iamvery/followers","following_url":"https://api.github.com/users/iamvery/following{/other_user}","gists_url":"https://api.github.com/users/iamvery/gists{/gist_id}","starred_url":"https://api.github.com/users/iamvery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iamvery/subscriptions","organizations_url":"https://api.github.com/users/iamvery/orgs","repos_url":"https://api.github.com/users/iamvery/repos","events_url":"https://api.github.com/users/iamvery/events{/privacy}","received_events_url":"https://api.github.com/users/iamvery/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/iamvery/rails","description":"Ruby on Rails","fork":true,"url":"https://api.github.com/repos/iamvery/rails","forks_url":"https://api.github.com/repos/iamvery/rails/forks","keys_url":"https://api.github.com/repos/iamvery/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iamvery/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iamvery/rails/teams","hooks_url":"https://api.github.com/repos/iamvery/rails/hooks","issue_events_url":"https://api.github.com/repos/iamvery/rails/issues/events{/number}","events_url":"https://api.github.com/repos/iamvery/rails/events","assignees_url":"https://api.github.com/repos/iamvery/rails/assignees{/user}","branches_url":"https://api.github.com/repos/iamvery/rails/branches{/branch}","tags_url":"https://api.github.com/repos/iamvery/rails/tags","blobs_url":"https://api.github.com/repos/iamvery/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iamvery/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iamvery/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/iamvery/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iamvery/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/iamvery/rails/languages","stargazers_url":"https://api.github.com/repos/iamvery/rails/stargazers","contributors_url":"https://api.github.com/repos/iamvery/rails/contributors","subscribers_url":"https://api.github.com/repos/iamvery/rails/subscribers","subscription_url":"https://api.github.com/repos/iamvery/rails/subscription","commits_url":"https://api.github.com/repos/iamvery/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/iamvery/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/iamvery/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/iamvery/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/iamvery/rails/contents/{+path}","compare_url":"https://api.github.com/repos/iamvery/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iamvery/rails/merges","archive_url":"https://api.github.com/repos/iamvery/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iamvery/rails/downloads","issues_url":"https://api.github.com/repos/iamvery/rails/issues{/number}","pulls_url":"https://api.github.com/repos/iamvery/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/iamvery/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/iamvery/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iamvery/rails/labels{/name}","releases_url":"https://api.github.com/repos/iamvery/rails/releases{/id}","created_at":"2012-12-13T20:07:03Z","updated_at":"2015-04-26T15:42:39Z","pushed_at":"2015-08-10T20:19:34Z","git_url":"git://github.com/iamvery/rails.git","ssh_url":"git@github.com:iamvery/rails.git","clone_url":"https://github.com/iamvery/rails.git","svn_url":"https://github.com/iamvery/rails","homepage":"http://rubyonrails.org","size":143586,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rails:master","ref":"master","sha":"17439e3a4027a813d8b746ea892c1c3373c26df3","user":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"repo":{"id":8514,"name":"rails","full_name":"rails/rails","owner":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails/rails","description":"Ruby on Rails","fork":false,"url":"https://api.github.com/repos/rails/rails","forks_url":"https://api.github.com/repos/rails/rails/forks","keys_url":"https://api.github.com/repos/rails/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails/rails/teams","hooks_url":"https://api.github.com/repos/rails/rails/hooks","issue_events_url":"https://api.github.com/repos/rails/rails/issues/events{/number}","events_url":"https://api.github.com/repos/rails/rails/events","assignees_url":"https://api.github.com/repos/rails/rails/assignees{/user}","branches_url":"https://api.github.com/repos/rails/rails/branches{/branch}","tags_url":"https://api.github.com/repos/rails/rails/tags","blobs_url":"https://api.github.com/repos/rails/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/rails/rails/languages","stargazers_url":"https://api.github.com/repos/rails/rails/stargazers","contributors_url":"https://api.github.com/repos/rails/rails/contributors","subscribers_url":"https://api.github.com/repos/rails/rails/subscribers","subscription_url":"https://api.github.com/repos/rails/rails/subscription","commits_url":"https://api.github.com/repos/rails/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/rails/rails/contents/{+path}","compare_url":"https://api.github.com/repos/rails/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails/rails/merges","archive_url":"https://api.github.com/repos/rails/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails/rails/downloads","issues_url":"https://api.github.com/repos/rails/rails/issues{/number}","pulls_url":"https://api.github.com/repos/rails/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/rails/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/rails/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails/rails/labels{/name}","releases_url":"https://api.github.com/repos/rails/rails/releases{/id}","created_at":"2008-04-11T02:19:47Z","updated_at":"2015-08-11T12:27:40Z","pushed_at":"2015-08-11T12:27:53Z","git_url":"git://github.com/rails/rails.git","ssh_url":"git@github.com:rails/rails.git","clone_url":"https://github.com/rails/rails.git","svn_url":"https://github.com/rails/rails","homepage":"http://rubyonrails.org","size":436125,"stargazers_count":27234,"watchers_count":27234,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":10930,"mirror_url":null,"open_issues_count":892,"forks":10930,"open_issues":892,"watchers":27234,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/20701"},"html":{"href":"https://github.com/rails/rails/pull/20701"},"issue":{"href":"https://api.github.com/repos/rails/rails/issues/20701"},"comments":{"href":"https://api.github.com/repos/rails/rails/issues/20701/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/rails/pulls/20701/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails/rails/pulls/20701/commits"},"statuses":{"href":"https://api.github.com/repos/rails/rails/statuses/2d9f54339cc8a45954e53af0d3085d7eb7ddfb3a"}}}}