From 807a9774a08a06ba17048ef0175602c0e8ffc41a Mon Sep 17 00:00:00 2001 From: Jay Hayes Date: Mon, 20 Aug 2012 09:56:07 -0500 Subject: Extended documentation for `time_ago_in_words` helper --- actionpack/lib/action_view/helpers/date_helper.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'actionpack/lib/action_view/helpers') 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 distance_of_time_in_words, but where to_time is fixed to Time.now. # + # The from_time argument must be of type Time rather than type Numeric. For example, + # to get the time_ago_in_words for 30 minutes you would use 30.minutes.ago as the argument + # rather than just 30.minutes. + # # 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 -- cgit v1.2.3