diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-11-12 03:05:18 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-11-12 03:05:18 +0000 |
commit | 79c309e43ba8832a8665fdec26e32062e5b2b830 (patch) | |
tree | 83f70531c2273a17dda67b1fa920325606601867 /activesupport/lib/active_support/core_ext | |
parent | da3eae49227f7cd5d7fd8bde2273d860ef90ac9d (diff) | |
download | rails-79c309e43ba8832a8665fdec26e32062e5b2b830.tar.gz rails-79c309e43ba8832a8665fdec26e32062e5b2b830.tar.bz2 rails-79c309e43ba8832a8665fdec26e32062e5b2b830.zip |
Added Time#end_of_day to get 23:59:59 of that day [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5495 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r-- | activesupport/lib/active_support/core_ext/time/calculations.rb | 5 |
1 files changed, 5 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 fb82513047..cdfcdf57d7 100644 --- a/activesupport/lib/active_support/core_ext/time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/time/calculations.rb @@ -149,6 +149,11 @@ module ActiveSupport #:nodoc: alias :at_midnight :beginning_of_day alias :at_beginning_of_day :beginning_of_day + # Returns a new Time representing the end of the day (23:59:59) + def end_of_day + change(:hour => 23, :minute => 59, :sec => 59) + end + # Returns a new Time representing the start of the month (1st of the month, 0:00) def beginning_of_month #self - ((self.mday-1).days + self.seconds_since_midnight) |