Sha256: 8856dd31e33bad1a305497936e0a7292504f926734024d758862fa276ffc13a3

Contents?: true

Size: 867 Bytes

Versions: 37

Compression:

Stored size: 867 Bytes

Contents

require 'active_support/duration'
require 'active_support/core_ext/numeric/time'

class Integer
  # Enables the use of time calculations and declarations, like <tt>45.minutes +
  # 2.hours + 4.years</tt>.
  #
  # These methods use Time#advance for precise date calculations when using
  # <tt>from_now</tt>, +ago+, etc. as well as adding or subtracting their
  # results from a Time object.
  #
  #   # equivalent to Time.now.advance(months: 1)
  #   1.month.from_now
  #
  #   # equivalent to Time.now.advance(years: 2)
  #   2.years.from_now
  #
  #   # equivalent to Time.now.advance(months: 4, years: 5)
  #   (4.months + 5.years).from_now
  def months
    ActiveSupport::Duration.new(self * 30.days, [[:months, self]])
  end
  alias :month :months

  def years
    ActiveSupport::Duration.new(self * 365.25.days, [[:years, self]])
  end
  alias :year :years
end

Version data entries

37 entries across 36 versions & 8 rubygems

Version Path
activesupport-4.2.11.3 lib/active_support/core_ext/integer/time.rb
activesupport-4.2.11.2 lib/active_support/core_ext/integer/time.rb
cocoapods-dependency-html-0.0.2 vendor/bundle/gems/activesupport-4.2.11.1/lib/active_support/core_ext/integer/time.rb
cocoapods-dependency-html-0.0.1 vendor/bundle/gems/activesupport-4.2.11.1/lib/active_support/core_ext/integer/time.rb
activesupport-4.2.11.1 lib/active_support/core_ext/integer/time.rb
activesupport-4.2.11 lib/active_support/core_ext/integer/time.rb
activesupport-4.2.10 lib/active_support/core_ext/integer/time.rb
activesupport-4.2.10.rc1 lib/active_support/core_ext/integer/time.rb
activesupport-4.2.9 lib/active_support/core_ext/integer/time.rb
activesupport-4.2.9.rc2 lib/active_support/core_ext/integer/time.rb
activesupport-4.2.9.rc1 lib/active_support/core_ext/integer/time.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activesupport-4.2.8/lib/active_support/core_ext/integer/time.rb
activesupport-4.2.8 lib/active_support/core_ext/integer/time.rb
activesupport-4.2.8.rc1 lib/active_support/core_ext/integer/time.rb
activesupport-4.2.7.1 lib/active_support/core_ext/integer/time.rb
activesupport-4.2.7 lib/active_support/core_ext/integer/time.rb
activesupport-4.2.7.rc1 lib/active_support/core_ext/integer/time.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/core_ext/integer/time.rb
activesupport-4.2.6 lib/active_support/core_ext/integer/time.rb
activesupport-4.2.6.rc1 lib/active_support/core_ext/integer/time.rb