aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2011-11-26 23:10:42 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2011-11-26 23:15:11 +0530
commit80ac4dc6d0632937ccf61b38bc15fc2f6e27b18b (patch)
treecda42275fcd1112fc5efa95ce31cf0c1dc2b8ad0 /activesupport
parenta8f2860d0e7db86c61bb70935006100b04667ab1 (diff)
downloadrails-80ac4dc6d0632937ccf61b38bc15fc2f6e27b18b.tar.gz
rails-80ac4dc6d0632937ccf61b38bc15fc2f6e27b18b.tar.bz2
rails-80ac4dc6d0632937ccf61b38bc15fc2f6e27b18b.zip
Adds Time#sunday method
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/time/calculations.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb
index 7075d6ab17..f3235d11bb 100644
--- a/activesupport/lib/active_support/core_ext/time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/time/calculations.rb
@@ -189,6 +189,12 @@ class Time
end
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 Time representing the start of the given day in the previous week (default is :monday).
def prev_week(day = :monday)
ago(1.week).beginning_of_week.since(DAYS_INTO_WEEK[day].day).change(:hour => 0)