aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/active_support_core_extensions.textile
diff options
context:
space:
mode:
authorgregolsen <anotheroneman@yahoo.com>2011-11-06 21:42:03 +0200
committerXavier Noria <fxn@hashref.com>2011-11-25 12:02:49 -0800
commit3f1a4c3415113f2d365eb1a5531757699afec605 (patch)
tree8f4a5c4306ad199f6a64b4970b0200eda58471df /railties/guides/source/active_support_core_extensions.textile
parent0a4035b12a6c59253cb60f9e3456513c6a6a9d33 (diff)
downloadrails-3f1a4c3415113f2d365eb1a5531757699afec605.tar.gz
rails-3f1a4c3415113f2d365eb1a5531757699afec605.tar.bz2
rails-3f1a4c3415113f2d365eb1a5531757699afec605.zip
beginning_of_week extended in both Time and Date so that to return week start based on start day that is monday by default
Diffstat (limited to 'railties/guides/source/active_support_core_extensions.textile')
-rw-r--r--railties/guides/source/active_support_core_extensions.textile10
1 files changed, 6 insertions, 4 deletions
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile
index ff6c5f967f..c6130f4f62 100644
--- a/railties/guides/source/active_support_core_extensions.textile
+++ b/railties/guides/source/active_support_core_extensions.textile
@@ -3039,12 +3039,14 @@ Active Support defines these methods as well for Ruby 1.8.
h6. +beginning_of_week+, +end_of_week+
-The methods +beginning_of_week+ and +end_of_week+ return the dates for the beginning and end of week, assuming weeks start on Monday:
+The methods +beginning_of_week+ and +end_of_week+ receive a symbol with a day name in English (in lowercase, default is :monday) and return the dates for the beginning and end of week, assuming weeks start on day, passed as parameter:
<ruby>
-d = Date.new(2010, 5, 8) # => Sat, 08 May 2010
-d.beginning_of_week # => Mon, 03 May 2010
-d.end_of_week # => Sun, 09 May 2010
+d = Date.new(2010, 5, 8) # => Sat, 08 May 2010
+d.beginning_of_week # => Mon, 03 May 2010
+d.beginning_of_week(:sunday) # => Sun, 02 May 2010
+d.end_of_week # => Sun, 09 May 2010
+d.end_of_week(:sunday) # => Sat, 08 May 2010
</ruby>
+beginning_of_week+ is aliased to +monday+ and +at_beginning_of_week+. +end_of_week+ is aliased to +sunday+ and +at_end_of_week+.