Module: RailsCom::TimeHelper
- Defined in:
- app/helpers/rails_com/time_helper.rb
Instance Method Summary collapse
- #exact_distance_time(from_time, to_time, options = {}) ⇒ Object
- #extra_distance_date(from, to, options = {}) ⇒ Object
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, = {}) result = TimeHelper.exact_distance_time(from_time, to_time) = { scope: :'datetime.prompts' }.merge!() I18n. locale: [:locale], scope: [: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 |
#extra_distance_date(from, to, options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/helpers/rails_com/time_helper.rb', line 23 def extra_distance_date(from, to, = {}) result = (to - from).to_i = { scope: :'date.distance_in_words' }.merge!() I18n. locale: [:locale], scope: [:scope] do |locale| case result when 0 locale.t :zero when 1 locale.t :one when 2 locale.t :two when 3 locale.t :three else locale.t :other, count: result end end end |