aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/time
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-06-16 18:27:20 +0900
committerGitHub <noreply@github.com>2019-06-16 18:27:20 +0900
commit6a033a06855f0b7a407ff8edbfc9f9aa45527edc (patch)
tree4f8c38b353e29c9e99cc1492d675da8fb1a8a39e /activesupport/lib/active_support/core_ext/time
parentbf0570e8d71aaec991160e67c67ec34359344282 (diff)
parentbfecb7d3b6291f1b29ad71023a43c21480b53d55 (diff)
downloadrails-6a033a06855f0b7a407ff8edbfc9f9aa45527edc.tar.gz
rails-6a033a06855f0b7a407ff8edbfc9f9aa45527edc.tar.bz2
rails-6a033a06855f0b7a407ff8edbfc9f9aa45527edc.zip
Merge pull request #36497 from soartec-lab/move_date_and_time_method_to_time
Delete method definition in rails that is compatible with ruby definiā€¦
Diffstat (limited to 'activesupport/lib/active_support/core_ext/time')
-rw-r--r--activesupport/lib/active_support/core_ext/time/calculations.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb
index f09a6271ad..eed34965e3 100644
--- a/activesupport/lib/active_support/core_ext/time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/time/calculations.rb
@@ -311,4 +311,34 @@ class Time
end
alias_method :eql_without_coercion, :eql?
alias_method :eql?, :eql_with_coercion
+
+ # Returns a new time the specified number of days ago.
+ def prev_day(days = 1)
+ advance(days: -days)
+ end
+
+ # Returns a new time the specified number of days in the future.
+ def next_day(days = 1)
+ advance(days: days)
+ end
+
+ # Returns a new time the specified number of months ago.
+ def prev_month(months = 1)
+ advance(months: -months)
+ end
+
+ # Returns a new time the specified number of months in the future.
+ def next_month(months = 1)
+ advance(months: months)
+ end
+
+ # Returns a new time the specified number of years ago.
+ def prev_year(years = 1)
+ advance(years: -years)
+ end
+
+ # Returns a new time the specified number of years in the future.
+ def next_year(years = 1)
+ advance(years: years)
+ end
end