Apparent bug in DateHelper::distance_of_time_in_words (Rails 2.3.2)

Hi,

There seems to be a rounding error in this method.

The problem lies in the following lines:

85: when 2880..43199 then locale.t :x_days, :count => (distance_in_minutes / 1440).round 87: when 86400..525599 then locale.t :x_months, :count => (distance_in_minutes / 43200).round 89: else locale.t :over_x_years, :count => (distance_in_minutes / 525600).round

In the calculation (distance_in_minutes / 1440), we are actually dividing two integers, which of course means that the result of the division is truncated.

So for instance, if distance_in_minutes is 4319 minutes (just 1 minute short of 3 full days), then the result of this division is truncated to 2, and the method returns the string "2 days".

These changes correct the problem, by ensuring that the divisors are floats: 85: when 2880..43199 then locale.t :x_days, :count => (distance_in_minutes / 1440.0).round 87: when 86400..525599 then locale.t :x_months, :count => (distance_in_minutes / 43200.0).round 89: else locale.t :over_x_years, :count => (distance_in_minutes / 525600.0).round

So, does anyone know if this actually is a bug, or if there is something I'm missing? Line 83 already ensures that the division is performed with floats, so this case does not exhibit the problem I described: 83: when 90..1439 then locale.t :about_x_hours, :count => (distance_in_minutes.to_f / 60.0).round

I think this is a bug and I noticed it earlier but didn't think of
pointing it out, good work!