module ActionView::Helpers::DateHelper

Public Instance Methods

_distance_of_time_in_words(from_time, to_time = 0, include_seconds_or_options = {}, options = {})
distance_of_time_in_percent(from_time, current_time, to_time, options = {}) click to toggle source
# File lib/dotiw/action_view/helpers/date_helper.rb, line 25
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 = {}) click to toggle source
# 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 = {})
  options = merge_options(include_seconds_or_options, options)
  return _distance_of_time_in_words(from_time, to_time, options.except(:vague)) if options[:vague]

  DOTIW::Methods.distance_of_time_in_words(from_time, to_time, options.except(:vague))
end
Also aliased as: _distance_of_time_in_words
distance_of_time_in_words_to_now(to_time = 0, include_seconds_or_options = {}, options = {}) click to toggle source
# File lib/dotiw/action_view/helpers/date_helper.rb, line 18
def distance_of_time_in_words_to_now(to_time = 0, include_seconds_or_options = {}, options = {})
  options = merge_options(include_seconds_or_options, options)
  return _distance_of_time_in_words(Time.now, to_time, options.except(:vague)) if options[:vague]

  DOTIW::Methods.distance_of_time_in_words(Time.now, to_time, options.except(:vague))
end

Private Instance Methods

merge_options(include_seconds_or_options, options) click to toggle source
# File lib/dotiw/action_view/helpers/date_helper.rb, line 34
def merge_options(include_seconds_or_options, options)
  if include_seconds_or_options.is_a?(Hash)
    options.merge(include_seconds_or_options)
  else
    options.merge(include_seconds: !!include_seconds_or_options)
  end
end