aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date_time
diff options
context:
space:
mode:
authorGagan Awhad <gagan.awhad@desiringgod.org>2013-02-21 14:22:50 -0600
committerGagan Awhad <gagan.awhad@desiringgod.org>2013-02-21 16:14:16 -0600
commit6f380d37788a562c13d0d68b1d3f28f8a6f4b3ec (patch)
tree3f7a276045f28f46cfb3c0e40ca1edce4593eddf /activesupport/lib/active_support/core_ext/date_time
parent389397952460d09218bb407be1142e0b62cf3f4f (diff)
downloadrails-6f380d37788a562c13d0d68b1d3f28f8a6f4b3ec.tar.gz
rails-6f380d37788a562c13d0d68b1d3f28f8a6f4b3ec.tar.bz2
rails-6f380d37788a562c13d0d68b1d3f28f8a6f4b3ec.zip
Added beginning_of_minute support to core_ext calculations for Time and DateTime
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date_time')
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/calculations.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/date_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_time/calculations.rb
index 1d3682eaf2..82cc46aa37 100644
--- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb
@@ -123,6 +123,18 @@ class DateTime
change(:min => 59, :sec => 59)
end
alias :at_end_of_hour :end_of_hour
+
+ # Returns a new DateTime representing the start of the hour (hh:mm:00).
+ def beginning_of_minute
+ change(:sec => 0)
+ end
+ alias :at_beginning_of_minute :beginning_of_minute
+
+ # Returns a new DateTime representing the end of the minute (hh:mm:59).
+ def end_of_minute
+ change(:sec => 59)
+ end
+ alias :at_end_of_minute :end_of_minute
# Adjusts DateTime to UTC by adding its offset value; offset is set to 0.
#