]> source.dussan.org Git - redmine.git/commitdiff
Fixes distance of date in words calculation.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 7 Nov 2009 09:50:16 +0000 (09:50 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 7 Nov 2009 09:50:16 +0000 (09:50 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3016 e93f8b46-1217-0410-a6f0-8f06a7374b81

config/initializers/10-patches.rb
test/unit/helpers/application_helper_test.rb

index 94d40faaf21256a3af7f10b914678926da815f99..9aa416f5512a42a67d7d23a2ae959d1717590354 100644 (file)
@@ -53,9 +53,9 @@ module ActionView
 
         I18n.with_options :locale => options[:locale], :scope => :'datetime.distance_in_words' do |locale|
           case distance_in_days
-            when 0..60     then locale.t :x_days,             :count => distance_in_days
+            when 0..60     then locale.t :x_days,             :count => distance_in_days.round
             when 61..720   then locale.t :about_x_months,     :count => (distance_in_days / 30).round
-            else                locale.t :over_x_years,       :count => (distance_in_days / 365).round
+            else                locale.t :over_x_years,       :count => (distance_in_days / 365).floor
           end
         end
       end
index 27d6c473e081ca781682afa91136f57a97d9c91f..84fc3bd6ba0fbcc5a6aee9ffc958bb8eda19aff6 100644 (file)
@@ -461,10 +461,10 @@ EXPECTED
     to_test = { Date.today => 'Due in 0 days',
                 Date.today + 1 => 'Due in 1 day',
                 Date.today + 100 => 'Due in about 3 months',
-                Date.today + 20000 => 'Due in over 55 years',
+                Date.today + 20000 => 'Due in over 54 years',
                 Date.today - 1 => '1 day late',
                 Date.today - 100 => 'about 3 months late',
-                Date.today - 20000 => 'over 55 years late',
+                Date.today - 20000 => 'over 54 years late',
                }
     to_test.each do |date, expected|
       assert_equal expected, due_date_distance_in_words(date)