From 2773257ac64c82affae527436b08e6d627853c1d Mon Sep 17 00:00:00 2001 From: paranoiase Kang Date: Sun, 20 May 2012 14:33:58 +0900 Subject: Add prev_quarter and next_quarter method in Time/Date/DateTime --- .../lib/active_support/core_ext/time/calculations.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'activesupport/lib/active_support/core_ext/time/calculations.rb') diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb index 92b8417150..28c8b53b78 100644 --- a/activesupport/lib/active_support/core_ext/time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/time/calculations.rb @@ -186,6 +186,17 @@ class Time months_since(1) 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 number of days to start of this week, week starts on start_day (default is :monday). def days_to_week_start(start_day = :monday) start_day_number = DAYS_INTO_WEEK[start_day] -- cgit v1.2.3