aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2012-10-09 08:58:58 -0700
committerXavier Noria <fxn@hashref.com>2012-10-09 08:58:58 -0700
commit64dd0710206fd496f1dd486d22705034be83baf1 (patch)
tree586ad63402c6aeda5d4ec1821991994ea18a2231 /guides/source
parent2e0c6173bdac9e37131ea1ab621f51e554bde699 (diff)
parentf912437dd2ca1996a73d6bcf8196c54ce3b62978 (diff)
downloadrails-64dd0710206fd496f1dd486d22705034be83baf1.tar.gz
rails-64dd0710206fd496f1dd486d22705034be83baf1.tar.bz2
rails-64dd0710206fd496f1dd486d22705034be83baf1.zip
Merge pull request #7736 from gregolsen/beginning_of_week_guides
ActiveSupport core extensions guides update
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/active_support_core_extensions.md8
1 files changed, 6 insertions, 2 deletions
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md
index 2a84242b9c..1948cb0278 100644
--- a/guides/source/active_support_core_extensions.md
+++ b/guides/source/active_support_core_extensions.md
@@ -3097,7 +3097,8 @@ Time.local(2000, 11, 31).next_quarter # => Wed, 28 Feb 2001
The methods `beginning_of_week` and `end_of_week` return the dates for the
beginning and end of the week, respectively. Weeks are assumed to start on
-Monday, but that can be changed passing an argument.
+Monday, but that can be changed passing an argument, setting thread local
+`Date.beginning_of_week` or `config.beginning_of_week`.
```ruby
d = Date.new(2010, 5, 8) # => Sat, 08 May 2010
@@ -3122,7 +3123,7 @@ d.sunday # => Sun, 09 May 2010
##### `prev_week`, `next_week`
-The method `next_week` receives a symbol with a day name in English (in lowercase, default is `:monday`) and it returns the date corresponding to that day:
+The method `next_week` receives a symbol with a day name in English (default is `Date.beginning_of_week` or :monday if not set) and it returns the date corresponding to that day.
```ruby
d = Date.new(2010, 5, 9) # => Sun, 09 May 2010
@@ -3139,6 +3140,7 @@ d.prev_week(:friday) # => Fri, 30 Apr 2010
```
`prev_week` is aliased to `last_week`.
+Both `next_week` and `prev_week` work as expected when Date.beginning_of_week` or `config.beginning_of_week` is set.
##### `beginning_of_month`, `end_of_month`
@@ -3617,6 +3619,8 @@ now = Time.current
# => Mon, 09 Aug 2010 23:20:05 UTC +00:00
now.all_week
# => Mon, 09 Aug 2010 00:00:00 UTC +00:00..Sun, 15 Aug 2010 23:59:59 UTC +00:00
+now.all_week(:sunday)
+# => Sun, 16 Sep 2012 00:00:00 UTC +00:00..Sat, 22 Sep 2012 23:59:59 UTC +00:00
now.all_month
# => Sat, 01 Aug 2010 00:00:00 UTC +00:00..Tue, 31 Aug 2010 23:59:59 UTC +00:00
now.all_quarter