Module: RailsCom::TimeHelper

Defined in:
app/helpers/rails_com/time_helper.rb

Instance Method Summary collapse

Instance Method Details

#exact_distance_time(from_time, to_time, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/rails_com/time_helper.rb', line 4

def exact_distance_time(from_time, to_time, options = {})
  result = TimeHelper.exact_distance_time(from_time, to_time)

  options = {
    scope: :'datetime.prompts'
  }.merge!(options)

  I18n.with_options locale: options[:locale], scope: options[:scope] do |locale|
    str = ''
    result.each do |k, v|
      if v > 0
        str += v.to_s
        str += locale.t(k)
      end
    end
    str
  end
end