Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #7398 from iamvery/time_ago_in_words-docs

Extended documentation for `time_ago_in_words` helper
  • Loading branch information...
commit 8fbfeb1ef7bef5df912aede129b1bee57e9adf53 2 parents 5c89e07 + 807a977
@vijaydev vijaydev authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 actionpack/lib/action_view/helpers/date_helper.rb
View
7 actionpack/lib/action_view/helpers/date_helper.rb
@@ -139,6 +139,10 @@ def distance_of_time_in_words(from_time, to_time = 0, include_seconds_or_options
# Like <tt>distance_of_time_in_words</tt>, but where <tt>to_time</tt> is fixed to <tt>Time.now</tt>.
#
+ # The <tt>from_time</tt> argument must be of type <tt>Time</tt> rather than type <tt>Numeric</tt>. For example,
+ # to get the <tt>time_ago_in_words</tt> for 30 minutes you would use <tt>30.minutes.ago</tt> as the argument
+ # rather than just <tt>30.minutes</tt>.
+ #
# time_ago_in_words(3.minutes.from_now) # => 3 minutes
# time_ago_in_words(Time.now - 15.hours) # => about 15 hours
# time_ago_in_words(Time.now) # => less than a minute
@@ -146,6 +150,9 @@ def distance_of_time_in_words(from_time, to_time = 0, include_seconds_or_options
#
# from_time = Time.now - 3.days - 14.minutes - 25.seconds
# time_ago_in_words(from_time) # => 3 days
+ #
+ # from_time = (3.days + 14.minutes + 25.seconds).ago
+ # time_ago_in_words(from_time) # => 3 days
def time_ago_in_words(from_time, include_seconds_or_options = {})
distance_of_time_in_words(from_time, Time.now, include_seconds_or_options)
end
Please sign in to comment.
Something went wrong with that request. Please try again.