diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2011-11-26 22:26:52 +0530 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2011-11-26 23:08:58 +0530 |
commit | a8f2860d0e7db86c61bb70935006100b04667ab1 (patch) | |
tree | eb3cf04b0887bce9799914a0d61f3ddb568bc993 /activesupport/lib/active_support/core_ext/time | |
parent | 8135e5e6998f99bec56df365f1a580bae4bf1cb1 (diff) | |
download | rails-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/time')
-rw-r--r-- | activesupport/lib/active_support/core_ext/time/calculations.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb index 2cc5c82265..7075d6ab17 100644 --- a/activesupport/lib/active_support/core_ext/time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/time/calculations.rb @@ -174,9 +174,14 @@ class Time days_to_start = days_to_week_start(start_day) (self - days_to_start.days).midnight 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 Time representing the end of this week, week starts on start_day (default is :monday, i.e. end of Sunday). def end_of_week(start_day = :monday) days_to_end = 6 - days_to_week_start(start_day) |