instance method
change
Ruby on Rails 3.1.12
Since v3.0.20Signature
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
-
optionsreq
Source
# File activesupport/lib/active_support/core_ext/date/calculations.rb, line 124
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 124
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Date