aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date/calculations.rb
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/calculations.rb
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/calculations.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/date/calculations.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/date/calculations.rb b/activesupport/lib/active_support/core_ext/date/calculations.rb
index eddb1b851f..af048d0c85 100644
--- a/activesupport/lib/active_support/core_ext/date/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/date/calculations.rb
@@ -69,6 +69,16 @@ class Date
alias :at_midnight :beginning_of_day
alias :at_beginning_of_day :beginning_of_day
+ # Converts Date to a Time (or DateTime if necessary) with the time portion set to the middle of the day (12:00)
+ def middle_of_day
+ in_time_zone.middle_of_day
+ 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
+
# Converts Date to a Time (or DateTime if necessary) with the time portion set to the end of the day (23:59:59)
def end_of_day
in_time_zone.end_of_day