aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-06-20 11:42:21 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-06-20 11:42:21 -0300
commit4f700edcc094406155785c693363801d0277792c (patch)
treebbe0186dc87c3039abd13d59c39f8eee8bba14b1 /guides/source
parent265f13495fb326bd2e6a5bc9cae7e297e42893d0 (diff)
parent2773257ac64c82affae527436b08e6d627853c1d (diff)
downloadrails-4f700edcc094406155785c693363801d0277792c.tar.gz
rails-4f700edcc094406155785c693363801d0277792c.tar.bz2
rails-4f700edcc094406155785c693363801d0277792c.zip
Merge pull request #6402 from paranoiase/prev-and-next-quarter
Add prev_quarter and next_quarter methods in Time/Date/DateTime calculations. Similar to prev_month and next_month, it returns the date with the same day in the previous or next quarter: t = Time.local(2010, 5, 8) # => Sat, 08 May 2010 t.prev_quarter # => Mon, 08 Feb 2010 t.next_quarter # => Sun, 08 Aug 2010 Closes #6402
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/active_support_core_extensions.textile21
1 files changed, 21 insertions, 0 deletions
diff --git a/guides/source/active_support_core_extensions.textile b/guides/source/active_support_core_extensions.textile
index 40ef19cfbf..99b8bdd3fd 100644
--- a/guides/source/active_support_core_extensions.textile
+++ b/guides/source/active_support_core_extensions.textile
@@ -3045,6 +3045,27 @@ Date.new(2000, 1, 31).next_month # => Tue, 29 Feb 2000
+prev_month+ is aliased to +last_month+.
+h6. +prev_quarter+, +next_quarter+
+
+Same as +prev_month+ and +next_month+. It returns the date with the same day in the previous or next quarter:
+
+<ruby>
+t = Time.local(2010, 5, 8) # => Sat, 08 May 2010
+t.prev_quarter # => Mon, 08 Feb 2010
+t.next_quarter # => Sun, 08 Aug 2010
+</ruby>
+
+If such a day does not exist, the last day of the corresponding month is returned:
+
+<ruby>
+Time.local(2000, 7, 31).prev_quarter # => Sun, 30 Apr 2000
+Time.local(2000, 5, 31).prev_quarter # => Tue, 29 Feb 2000
+Time.local(2000, 10, 31).prev_quarter # => Mon, 30 Oct 2000
+Time.local(2000, 11, 31).next_quarter # => Wed, 28 Feb 2001
+</ruby>
+
++prev_quarter+ is aliased to +last_quarter+.
+
h6. +beginning_of_week+, +end_of_week+
The methods +beginning_of_week+ and +end_of_week+ return the dates for the