Skip to content

Commit

Permalink
Deprecation: remove deprecated :mday option from Time, Date, and Date…
Browse files Browse the repository at this point in the history
…Time#change.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7508 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jeremy committed Sep 18, 2007
1 parent 4f375d5 commit 3a696dd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*

* Deprecation: remove deprecated :mday option from Time, Date, and DateTime#change. [Jeremy Kemper]

* Fix JSON decoder with nested quotes and commas. #9579 [zdennis]

* Hash#to_xml doesn't double-unescape. #8806 [Ezran]
Expand Down
Expand Up @@ -87,7 +87,7 @@ def change(options)
::Date.new(
options[:year] || self.year,
options[:month] || self.month,
options[:day] || options[:mday] || self.day # mday is deprecated
options[:day] || self.day
)
end

Expand Down
Expand Up @@ -18,7 +18,7 @@ def change(options)
::DateTime.civil(
options[:year] || self.year,
options[:month] || self.month,
options[:day] || options[:mday] || self.day, # mday is deprecated
options[:day] || self.day,
options[:hour] || self.hour,
options[:min] || (options[:hour] ? 0 : self.min),
options[:sec] || ((options[:hour] || options[:min]) ? 0 : self.sec),
Expand Down
10 changes: 5 additions & 5 deletions activesupport/lib/active_support/core_ext/time/calculations.rb
Expand Up @@ -63,7 +63,7 @@ def change(options)
self.utc? ? :utc_time : :local_time,
options[:year] || self.year,
options[:month] || self.month,
options[:day] || options[:mday] || self.day, # mday is deprecated
options[:day] || self.day,
options[:hour] || self.hour,
options[:min] || (options[:hour] ? 0 : self.min),
options[:sec] || ((options[:hour] || options[:min]) ? 0 : self.sec),
Expand Down Expand Up @@ -121,7 +121,7 @@ def months_since(months)
max = ::Time.days_in_month(month, year)
mday = max if mday > max

change(:year => year, :month => month, :mday => mday)
change(:year => year, :month => month, :day => mday)
end

# Returns a new Time representing the time a number of specified years ago
Expand Down Expand Up @@ -184,15 +184,15 @@ def end_of_day
# Returns a new Time representing the start of the month (1st of the month, 0:00)
def beginning_of_month
#self - ((self.mday-1).days + self.seconds_since_midnight)
change(:mday => 1,:hour => 0, :min => 0, :sec => 0, :usec => 0)
change(:day => 1,:hour => 0, :min => 0, :sec => 0, :usec => 0)
end
alias :at_beginning_of_month :beginning_of_month

# Returns a new Time representing the end of the month (last day of the month, 0:00)
def end_of_month
#self - ((self.mday-1).days + self.seconds_since_midnight)
last_day = ::Time.days_in_month( self.month, self.year )
change(:mday => last_day,:hour => 0, :min => 0, :sec => 0, :usec => 0)
change(:day => last_day,:hour => 0, :min => 0, :sec => 0, :usec => 0)
end
alias :at_end_of_month :end_of_month

Expand All @@ -204,7 +204,7 @@ def beginning_of_quarter

# Returns a new Time representing the start of the year (1st of january, 0:00)
def beginning_of_year
change(:month => 1,:mday => 1,:hour => 0, :min => 0, :sec => 0, :usec => 0)
change(:month => 1,:day => 1,:hour => 0, :min => 0, :sec => 0, :usec => 0)
end
alias :at_beginning_of_year :beginning_of_year

Expand Down

0 comments on commit 3a696dd

Please sign in to comment.