diff options
author | Henrik Nyh <henrik@nyh.se> | 2016-05-09 16:06:19 +0100 |
---|---|---|
committer | Henrik Nyh <henrik@nyh.se> | 2016-05-11 21:25:06 +0100 |
commit | f005202972cdb864327c854404fd18510e00f963 (patch) | |
tree | 095b34506f4c1a86dac30186ff1e9e862617aa88 /activesupport/lib | |
parent | a0b3de3002bd9f608b3a9e41e702762b10430207 (diff) | |
download | rails-f005202972cdb864327c854404fd18510e00f963.tar.gz rails-f005202972cdb864327c854404fd18510e00f963.tar.bz2 rails-f005202972cdb864327c854404fd18510e00f963.zip |
Introduce Date#all_day
Useful for queries like:
Item.where(created_at: Date.current.all_day)
There was already a Time#all_day with the same behaviour, but for
queries like the above, Date is more convenient.
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/date_and_time/calculations.rb | 5 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/time/calculations.rb | 5 |
2 files changed, 5 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb index 4da7fdd159..6206546672 100644 --- a/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb @@ -294,6 +294,11 @@ module DateAndTime end alias :at_end_of_year :end_of_year + # Returns a Range representing the whole day of the current date/time. + def all_day + beginning_of_day..end_of_day + end + # Returns a Range representing the whole week of the current date/time. # Week starts on start_day, default is <tt>Date.week_start</tt> or <tt>config.week_start</tt> when set. def all_week(start_day = Date.beginning_of_week) diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb index b755726db2..e81b48ab26 100644 --- a/activesupport/lib/active_support/core_ext/time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/time/calculations.rb @@ -227,11 +227,6 @@ class Time end alias :at_end_of_minute :end_of_minute - # Returns a Range representing the whole day of the current time. - def all_day - beginning_of_day..end_of_day - end - def plus_with_duration(other) #:nodoc: if ActiveSupport::Duration === other other.since(self) |