diff options
author | Jamis Buck <jamis@37signals.com> | 2005-06-14 15:19:03 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-06-14 15:19:03 +0000 |
commit | ed7bfc96625d47ba5905628d458c2daef238f32a (patch) | |
tree | ac23101aea344f4c0d42b78d1ccd1de5224a7a4a /actionpack/lib/action_view/helpers/date_helper.rb | |
parent | 3cb869eab6fec4b4310079af0409f6139ed7619c (diff) | |
download | rails-ed7bfc96625d47ba5905628d458c2daef238f32a.tar.gz rails-ed7bfc96625d47ba5905628d458c2daef238f32a.tar.bz2 rails-ed7bfc96625d47ba5905628d458c2daef238f32a.zip |
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
Diffstat (limited to 'actionpack/lib/action_view/helpers/date_helper.rb')
-rwxr-xr-x | actionpack/lib/action_view/helpers/date_helper.rb | 2 |
1 files changed, 2 insertions, 0 deletions
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 <tt>include_seconds</tt> 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 |