instance method change

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

change(options)

Returns a new Date where one or more of the elements have been changed according to the options parameter.

Examples:

Date.new(2007, 5, 12).change(:day => 1)                  # => Date.new(2007, 5, 1)
Date.new(2007, 5, 12).change(:year => 2005, :month => 1) # => Date.new(2005, 1, 12)

Parameters

options req
Source
# File activesupport/lib/active_support/core_ext/date/calculations.rb, line 109
        def change(options)
          ::Date.new(
            options[:year]  || self.year,
            options[:month] || self.month,
            options[:day]   || self.day
          )
        end

Defined in activesupport/lib/active_support/core_ext/date/calculations.rb line 109 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::CoreExtensions::Date::Calculations

Type at least 2 characters to search.

↑↓ navigate · open · esc close