aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_support_core_extensions.textile
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 /guides/source/active_support_core_extensions.textile
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 'guides/source/active_support_core_extensions.textile')
-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