Module: ActionView::Helpers::DateHelper

Includes:
DOTIW::Methods
Defined in:
lib/dotiw/action_view/helpers/date_helper.rb

Instance Method Summary collapse

Methods included from DOTIW::Methods

#distance_of_time, #distance_of_time_in_words_hash, #time_ago_in_words

Instance Method Details

#_distance_of_time_in_wordsObject



6
# File 'lib/dotiw/action_view/helpers/date_helper.rb', line 6

alias_method :_distance_of_time_in_words, :distance_of_time_in_words

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



16
17
18
19
20
21
22
# File 'lib/dotiw/action_view/helpers/date_helper.rb', line 16

def distance_of_time_in_percent(from_time, current_time, to_time, options = {})
  options[:precision] ||= 0
  options = options_with_scope(options)
  distance = to_time - from_time
  result = ((current_time - from_time) / distance) * 100
  number_with_precision(result, options).to_s + '%'
end

#distance_of_time_in_words(from_time, to_time = 0, include_seconds_or_options = {}, options = {}) ⇒ Object



11
12
13
14
# File 'lib/dotiw/action_view/helpers/date_helper.rb', line 11

def distance_of_time_in_words(from_time, to_time = 0, include_seconds_or_options = {}, options = {})
  return _distance_of_time_in_words(from_time, to_time, options) if options.delete(:vague)
  DOTIW::Methods.distance_of_time_in_words(from_time, to_time, include_seconds_or_options, options)
end