aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date_time
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2013-07-29 10:25:06 -0700
committerAndrew White <andyw@pixeltrix.co.uk>2013-07-29 10:25:06 -0700
commitc90105613188a088b9834a701e3ab15fa3e92bad (patch)
tree031b3b717ab637f58961d49b4fd437cc5996bca2 /activesupport/lib/active_support/core_ext/date_time
parentb51786d26e8262534f043c5c614b9e04cd33dbc1 (diff)
parent1b6bbb09532e164bf373c1cd273e4ec9062b9e56 (diff)
downloadrails-c90105613188a088b9834a701e3ab15fa3e92bad.tar.gz
rails-c90105613188a088b9834a701e3ab15fa3e92bad.tar.bz2
rails-c90105613188a088b9834a701e3ab15fa3e92bad.zip
Merge pull request #10879 from makaroni4/master
Added Time#middle_of_day method
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date_time')
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/calculations.rb10
1 files changed, 10 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 7d4f716bb6..c288a1f9bd 100644
--- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb
@@ -99,6 +99,16 @@ class DateTime
alias :at_midnight :beginning_of_day
alias :at_beginning_of_day :beginning_of_day
+ # Returns a new DateTime representing the middle of the day (12:00)
+ def middle_of_day
+ change(:hour => 12)
+ end
+ alias :midday :middle_of_day
+ alias :noon :middle_of_day
+ alias :at_midday :middle_of_day
+ alias :at_noon :middle_of_day
+ alias :at_middle_of_day :middle_of_day
+
# Returns a new DateTime representing the end of the day (23:59:59).
def end_of_day
change(:hour => 23, :min => 59, :sec => 59)