diff options
author | paranoiase Kang <paranoiase@gmail.com> | 2012-05-20 14:33:58 +0900 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-06-20 11:39:11 -0300 |
commit | 2773257ac64c82affae527436b08e6d627853c1d (patch) | |
tree | bbe0186dc87c3039abd13d59c39f8eee8bba14b1 /activesupport/lib/active_support/core_ext/time/calculations.rb | |
parent | 1bb2f5a8316c3e94b47b9cfb8fa519e1b1238869 (diff) | |
download | rails-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/time/calculations.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/time/calculations.rb | 11 |
1 files changed, 11 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 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] |