aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/time
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/time
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/time')
-rw-r--r--activesupport/lib/active_support/core_ext/time/calculations.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb
index 5e433f5dd9..5cf2715753 100644
--- a/activesupport/lib/active_support/core_ext/time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/time/calculations.rb
@@ -145,6 +145,7 @@ class Time
def prev_year
years_ago(1)
end
+ alias_method :last_year, :prev_year
# Short-hand for years_since(1)
def next_year
@@ -155,6 +156,7 @@ class Time
def prev_month
months_ago(1)
end
+ alias_method :last_month, :prev_month
# Short-hand for months_since(1)
def next_month
@@ -199,6 +201,7 @@ class Time
def prev_week(day = :monday)
ago(1.week).beginning_of_week.since(DAYS_INTO_WEEK[day].day).change(:hour => 0)
end
+ alias_method :last_week, :prev_week
# Returns a new Time representing the start of the given day in next week (default is :monday).
def next_week(day = :monday)