aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date
diff options
context:
space:
mode:
authorMatt Bridges <mbridges.91@gmail.com>2012-01-03 19:53:13 -0600
committerMatt Bridges <mbridges.91@gmail.com>2012-02-21 16:27:08 -0600
commitd6366625e04c516bf5f4bd6f561c3bb1945b0c82 (patch)
tree34c9ada6ee0e422235ec3cfeed7439806ebdfa50 /activesupport/lib/active_support/core_ext/date
parent7cfd1bd76a41bea528c945d821a9fbc3902af479 (diff)
downloadrails-d6366625e04c516bf5f4bd6f561c3bb1945b0c82.tar.gz
rails-d6366625e04c516bf5f4bd6f561c3bb1945b0c82.tar.bz2
rails-d6366625e04c516bf5f4bd6f561c3bb1945b0c82.zip
Adding :last_week, :last_month, and :last_year aliases to Time and Date
core extensions
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date')
-rw-r--r--activesupport/lib/active_support/core_ext/date/calculations.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/date/calculations.rb b/activesupport/lib/active_support/core_ext/date/calculations.rb
index af78226c21..6d4270f8b0 100644
--- a/activesupport/lib/active_support/core_ext/date/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/date/calculations.rb
@@ -182,6 +182,13 @@ class Date
result = (self - 7).beginning_of_week + DAYS_INTO_WEEK[day]
self.acts_like?(:time) ? result.change(:hour => 0) : result
end
+ alias :last_week :prev_week
+
+ # Alias of prev_month
+ alias :last_month :prev_month
+
+ # Alias of prev_year
+ alias :last_year :prev_year
# Returns a new Date/DateTime representing the start of the given day in next week (default is :monday).
def next_week(day = :monday)