diff options
author | Anatoli Makarevich <makaroni4@gmail.com> | 2013-06-07 18:37:41 +0400 |
---|---|---|
committer | Anatoli Makarevich <makaroni4@gmail.com> | 2013-07-28 23:29:50 +0400 |
commit | 1b6bbb09532e164bf373c1cd273e4ec9062b9e56 (patch) | |
tree | 3e55dbc0f5d840ec6f79ddb4c88e4354a4802775 /activesupport/lib/active_support/core_ext/date_time | |
parent | 94725b81f5588e4b0f43222c4f142c3135941b4b (diff) | |
download | rails-1b6bbb09532e164bf373c1cd273e4ec9062b9e56.tar.gz rails-1b6bbb09532e164bf373c1cd273e4ec9062b9e56.tar.bz2 rails-1b6bbb09532e164bf373c1cd273e4ec9062b9e56.zip |
Added Time#middle_of_day
Added middle_of_day method to Date 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.rb | 10 |
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 937567440b..b718ae10c3 100644 --- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb @@ -107,6 +107,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) |