aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Hayes <ur@iamvery.com>2012-08-20 09:56:07 -0500
committerJay Hayes <ur@iamvery.com>2012-08-20 10:03:16 -0500
commit807a9774a08a06ba17048ef0175602c0e8ffc41a (patch)
tree70257406011a124a431abfb7970bcc0366b0ee36
parentdb78e58294c5e4ee6fb960c79f882c80b22afbcf (diff)
downloadrails-807a9774a08a06ba17048ef0175602c0e8ffc41a.tar.gz
rails-807a9774a08a06ba17048ef0175602c0e8ffc41a.tar.bz2
rails-807a9774a08a06ba17048ef0175602c0e8ffc41a.zip
Extended documentation for `time_ago_in_words` helper
-rw-r--r--actionpack/lib/action_view/helpers/date_helper.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index dea2aa69dd..0403aac596 100644
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -139,6 +139,10 @@ module ActionView
# 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 @@ module ActionView
#
# 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