Sha256: 755c529f757d1c1949b6440c32274f37080d58f1291cbef74d1fe664c13fe902
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true module ActionView module Helpers module DateHelper alias _distance_of_time_in_words distance_of_time_in_words alias _time_ago_in_words time_ago_in_words include DOTIW::Methods 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[:vague] DOTIW::Methods.distance_of_time_in_words(from_time, to_time, include_seconds_or_options, options.except(:vague)) end def distance_of_time_in_words_to_now(to_time = 0, include_seconds_or_options = {}, options = {}) return _distance_of_time_in_words(Time.now, to_time, options) if options[:vague] DOTIW::Methods.distance_of_time_in_words(Time.now, to_time, include_seconds_or_options, options.except(:vague)) end 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 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dotiw-5.3.1 | lib/dotiw/action_view/helpers/date_helper.rb |
dotiw-5.3.0 | lib/dotiw/action_view/helpers/date_helper.rb |