Module | ActionView::Helpers::DateHelper
In: | vendor/plugins/brazilian-rails/lib/action_view_portuguese.rb

### Methods

distance_of_time_in_words

### Public Instance methods

distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)

[Source]

        # File vendor/plugins/brazilian-rails/lib/action_view_portuguese.rb, line 32
    32:   def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)
    33:     from_time = from_time.to_time if from_time.respond_to?(:to_time)
    34:     to_time = to_time.to_time if to_time.respond_to?(:to_time)
    35:     distance_in_minutes = (((to_time - from_time).abs)/60).round
    36:     distance_in_seconds = ((to_time - from_time).abs).round
    37:
    38:     case distance_in_minutes
    39:     when 0..1
    40:       return (distance_in_minutes == 0) ? 'menos de um minuto' : '1 minuto' unless include_seconds
    41:       case distance_in_seconds
    42:       when 0..4   then 'menos de 5 segundos'
    43:       when 5..9   then 'menos de 10 segundos'
    44:       when 10..19 then 'menos de 20 segundos'
    45:       when 20..39 then 'meio minuto'
    46:       when 40..59 then 'menos de um minuto'
    47:       else             '1 minuto'
    48:       end
    49:
    50:     when 2..44           then "#{distance_in_minutes} minutos"
    51:     when 45..89          then 'aproximadamente 1 hora'
    52:     when 90..1439        then "aproximadamente #{(distance_in_minutes.to_f / 60.0).round} horas"
    53:     when 1440..2879      then '1 dia'
    54:     when 2880..43199     then "#{(distance_in_minutes / 1440).round} dias"
    55:     when 43200..86399    then 'aproximadamente 1 mês'
    56:     when 86400..525959   then "#{(distance_in_minutes / 43200).round} meses"
    57:     when 525960..1051919 then 'aproximadamente 1 ano'
    58:     else                      "mais de #{(distance_in_minutes / 525960).round} anos"
    59:     end
    60:   end

[Validate]