aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date/calculations.rb
diff options
context:
space:
mode:
authorparanoiase Kang <paranoiase@gmail.com>2012-05-20 14:33:58 +0900
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-06-20 11:39:11 -0300
commit2773257ac64c82affae527436b08e6d627853c1d (patch)
treebbe0186dc87c3039abd13d59c39f8eee8bba14b1 /activesupport/lib/active_support/core_ext/date/calculations.rb
parent1bb2f5a8316c3e94b47b9cfb8fa519e1b1238869 (diff)
downloadrails-2773257ac64c82affae527436b08e6d627853c1d.tar.gz
rails-2773257ac64c82affae527436b08e6d627853c1d.tar.bz2
rails-2773257ac64c82affae527436b08e6d627853c1d.zip
Add prev_quarter and next_quarter method in Time/Date/DateTime
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date/calculations.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/date/calculations.rb11
1 files changed, 11 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 8a7eb6bc6b..7fe4161fb4 100644
--- a/activesupport/lib/active_support/core_ext/date/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/date/calculations.rb
@@ -202,6 +202,17 @@ class Date
acts_like?(:time) ? result.change(:hour => 0) : result
end
+ # Short-hand for months_ago(3)
+ def prev_quarter
+ months_ago(3)
+ end
+ alias_method :last_quarter, :prev_quarter
+
+ # Short-hand for months_since(3)
+ def next_quarter
+ months_since(3)
+ end
+
# Returns a new Date/DateTime representing the start of the month (1st of the month; DateTime objects will have time set to 0:00)
def beginning_of_month
acts_like?(:time) ? change(:day => 1, :hour => 0) : change(:day => 1)