diff options
author | Yves Senn <yves.senn@gmail.com> | 2015-05-07 15:48:05 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2015-05-07 15:53:18 +0200 |
commit | 64ed04ee78bd8d08bd91e997a0b93172be9d9f35 (patch) | |
tree | fb2392ddab017522989d1e3d6da6b90cb601f93a /activesupport/lib | |
parent | d27974d3fb38918d323dcce3ae439ef68b369b72 (diff) | |
parent | c1025bdff02a200d07ece5539829ea1591d2f4b4 (diff) | |
download | rails-64ed04ee78bd8d08bd91e997a0b93172be9d9f35.tar.gz rails-64ed04ee78bd8d08bd91e997a0b93172be9d9f35.tar.bz2 rails-64ed04ee78bd8d08bd91e997a0b93172be9d9f35.zip |
Merge pull request #20049 from iamvery/patch-1
Amend `next_week` documentation [ci skip]
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/date_and_time/calculations.rb | 14 |
1 files changed, 13 insertions, 1 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 9525c10112..01153606c9 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 @@ -125,9 +125,21 @@ module DateAndTime alias :at_beginning_of_year :beginning_of_year # Returns a new date/time representing the given day in the next week. + # + # today = Date.today # => Thu, 07 May 2015 + # today.next_week # => Mon, 11 May 2015 + # # The +given_day_in_next_week+ defaults to the beginning of the week # which is determined by +Date.beginning_of_week+ or +config.beginning_of_week+ - # when set. +DateTime+ objects have their time set to 0:00 unless +same_time+ is true. + # when set. + # + # today = Date.today # => Thu, 07 May 2015 + # today.next_week(:friday) # => Fri, 15 May 2015 + # + # +DateTime+ objects have their time set to 0:00 unless +same_time+ is true. + # + # now = Time.current # => Thu, 07 May 2015 13:31:16 UTC +00:00 + # now.next_week # => Mon, 11 May 2015 00:00:00 UTC +00:00 def next_week(given_day_in_next_week = Date.beginning_of_week, same_time: false) result = first_hour(weeks_since(1).beginning_of_week.days_since(days_span(given_day_in_next_week))) same_time ? copy_time_to(result) : result |