aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorAlexey Vakhov <vakhov@gmail.com>2012-04-24 08:49:02 +0400
committerAlexey Vakhov <vakhov@gmail.com>2012-04-24 15:56:35 +0400
commitff5b0d699d7cef29a45e51890c6b781a0e70925f (patch)
tree78959942a5db91674d854281211ffe5d62831a1b /actionpack/lib/action_view
parent0b05380ea77a778b660f2e28e0f080c340c32daf (diff)
downloadrails-ff5b0d699d7cef29a45e51890c6b781a0e70925f.tar.gz
rails-ff5b0d699d7cef29a45e51890c6b781a0e70925f.tar.bz2
rails-ff5b0d699d7cef29a45e51890c6b781a0e70925f.zip
Distance of time in words should work correct if from time > to_time
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/helpers/date_helper.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index 1f237cd013..c77ec62cae 100644
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -67,8 +67,9 @@ module ActionView
def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false, options = {})
from_time = from_time.to_time if from_time.respond_to?(:to_time)
to_time = to_time.to_time if to_time.respond_to?(:to_time)
- distance_in_minutes = (((to_time - from_time).abs)/60).round
- distance_in_seconds = ((to_time - from_time).abs).round
+ from_time, to_time = to_time, from_time if from_time > to_time
+ distance_in_minutes = ((to_time - from_time)/60).round
+ distance_in_seconds = (to_time - from_time).round
I18n.with_options :locale => options[:locale], :scope => :'datetime.distance_in_words' do |locale|
case distance_in_minutes