##// END OF EJS Templates
Fixes distance of date in words calculation....
Jean-Philippe Lang -
r2902:86a9d90f07d6
parent child
Show More
@@ -53,9 +53,9 module ActionView
53 53
54 54 I18n.with_options :locale => options[:locale], :scope => :'datetime.distance_in_words' do |locale|
55 55 case distance_in_days
56 when 0..60 then locale.t :x_days, :count => distance_in_days
56 when 0..60 then locale.t :x_days, :count => distance_in_days.round
57 57 when 61..720 then locale.t :about_x_months, :count => (distance_in_days / 30).round
58 else locale.t :over_x_years, :count => (distance_in_days / 365).round
58 else locale.t :over_x_years, :count => (distance_in_days / 365).floor
59 59 end
60 60 end
61 61 end
@@ -461,10 +461,10 EXPECTED
461 461 to_test = { Date.today => 'Due in 0 days',
462 462 Date.today + 1 => 'Due in 1 day',
463 463 Date.today + 100 => 'Due in about 3 months',
464 Date.today + 20000 => 'Due in over 55 years',
464 Date.today + 20000 => 'Due in over 54 years',
465 465 Date.today - 1 => '1 day late',
466 466 Date.today - 100 => 'about 3 months late',
467 Date.today - 20000 => 'over 55 years late',
467 Date.today - 20000 => 'over 54 years late',
468 468 }
469 469 to_test.each do |date, expected|
470 470 assert_equal expected, due_date_distance_in_words(date)
General Comments 0
You need to be logged in to leave comments. Login now