303
304
305
306
307
308
309
310
311
312
313
314
315
|
# File 'app/helpers/base_helper.rb', line 303
def time_ago_in_words(from_time, to_time = Time.now, include_seconds = false)
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
case distance_in_minutes
when 0 then :a_few_seconds_ago.l
when 1..59 then :minutes_ago.l(:count => distance_in_minutes)
when 60..1440 then :hours_ago.l(:count => (distance_in_minutes.to_f / 60.0).round)
when 1440..2880 then :days_ago.l(:count => (distance_in_minutes.to_f / 1440.0).round)
else I18n.l(from_time, :format => :short)
end
end
|