From ed7bfc96625d47ba5905628d458c2daef238f32a Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Tue, 14 Jun 2005 15:19:03 +0000 Subject: Allow distance_of_time_in_words to work with any value that responds to #to_time (like dates) #969 git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1420 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/helpers/date_helper.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'actionpack/lib/action_view/helpers/date_helper.rb') diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index 53bba0b217..6b1fbf7268 100755 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -17,6 +17,8 @@ module ActionView # "about 1 hour". See the source for the complete wording list. #Set include_seconds to true if you want more detailed approximations if distance < 1 minute def distance_of_time_in_words(from_time, to_time, include_seconds = false) + from_time = from_time.to_time + to_time = to_time.to_time distance_in_minutes = ((to_time - from_time) / 60).round.abs distance_in_seconds = ((to_time - from_time)).round.abs -- cgit v1.2.3