aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date/calculations.rb
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2011-11-26 22:26:52 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2011-11-26 23:08:58 +0530
commita8f2860d0e7db86c61bb70935006100b04667ab1 (patch)
treeeb3cf04b0887bce9799914a0d61f3ddb568bc993 /activesupport/lib/active_support/core_ext/date/calculations.rb
parent8135e5e6998f99bec56df365f1a580bae4bf1cb1 (diff)
downloadrails-a8f2860d0e7db86c61bb70935006100b04667ab1.tar.gz
rails-a8f2860d0e7db86c61bb70935006100b04667ab1.tar.bz2
rails-a8f2860d0e7db86c61bb70935006100b04667ab1.zip
Convert aliases monday and sunday to methods
A recent change to beginning_of_week and end_of_week added an argument that can be used to specify the week's starting day as a symbol. Now these methods were aliased as monday and sunday respectively which as a consequence of the argument addition, made calls like obj.monday(:sunday) possible. This commit makes them methods on their own.
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date/calculations.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/date/calculations.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/date/calculations.rb b/activesupport/lib/active_support/core_ext/date/calculations.rb
index 8e7682ae12..f0f67765c6 100644
--- a/activesupport/lib/active_support/core_ext/date/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/date/calculations.rb
@@ -190,9 +190,14 @@ class Date
result = self - days_to_start
acts_like?(:time) ? result.midnight : result
end
- alias :monday :beginning_of_week
alias :at_beginning_of_week :beginning_of_week
+ # Returns a new +Date+/+DateTime+ representing the start of this week. Week is
+ # assumed to start on a Monday. +DateTime+ objects have their time set to 0:00.
+ def monday
+ beginning_of_week
+ end
+
# Returns a new +Date+/+DateTime+ representing the end of this week. Week is
# assumed to start on +start_day+, default is +:monday+. +DateTime+ objects
# have their time set to 23:59:59.
@@ -201,9 +206,14 @@ class Date
result = self + days_to_end.days
self.acts_like?(:time) ? result.end_of_day : result
end
- alias :sunday :end_of_week
alias :at_end_of_week :end_of_week
+ # Returns a new +Date+/+DateTime+ representing the end of this week. Week is
+ # assumed to start on a Monday. +DateTime+ objects have their time set to 23:59:59.
+ def sunday
+ end_of_week
+ end
+
# Returns a new +Date+/+DateTime+ representing the given +day+ in the previous
# week. Default is +:monday+. +DateTime+ objects have their time set to 0:00.
def prev_week(day = :monday)