aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorsoartec-lab <info@soartec-lab.work>2019-06-16 11:05:01 +0900
committersoartec-lab <info@soartec-lab.work>2019-06-16 18:11:39 +0900
commitbfecb7d3b6291f1b29ad71023a43c21480b53d55 (patch)
tree4f8c38b353e29c9e99cc1492d675da8fb1a8a39e /activesupport/lib
parentbf0570e8d71aaec991160e67c67ec34359344282 (diff)
downloadrails-bfecb7d3b6291f1b29ad71023a43c21480b53d55.tar.gz
rails-bfecb7d3b6291f1b29ad71023a43c21480b53d55.tar.bz2
rails-bfecb7d3b6291f1b29ad71023a43c21480b53d55.zip
Delete `DateAndTime` method definition in rails that is compatible with ruby definition
Tests are also only on the `Time` class Update doc forgetting to erase when moved Update guide `Date` class to `Time` class and defined file Update guide correction omission
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/date_and_time/calculations.rb30
-rw-r--r--activesupport/lib/active_support/core_ext/time/calculations.rb30
2 files changed, 30 insertions, 30 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 e2e11545e2..c7a2378e41 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
@@ -20,21 +20,11 @@ module DateAndTime
advance(days: -1)
end
- # Returns a new date/time the specified number of days ago.
- def prev_day(days = 1)
- advance(days: -days)
- end
-
# Returns a new date/time representing tomorrow.
def tomorrow
advance(days: 1)
end
- # Returns a new date/time the specified number of days in the future.
- def next_day(days = 1)
- advance(days: days)
- end
-
# Returns true if the date/time is today.
def today?
to_date == ::Date.current
@@ -198,21 +188,11 @@ module DateAndTime
end
end
- # Returns a new date/time the specified number of months in the future.
- def next_month(months = 1)
- advance(months: months)
- end
-
# Short-hand for months_since(3)
def next_quarter
months_since(3)
end
- # Returns a new date/time the specified number of years in the future.
- def next_year(years = 1)
- advance(years: years)
- end
-
# Returns a new date/time representing the given day in the previous week.
# Week is assumed to start on +start_day+, default is
# +Date.beginning_of_week+ or +config.beginning_of_week+ when set.
@@ -233,11 +213,6 @@ module DateAndTime
end
alias_method :last_weekday, :prev_weekday
- # Returns a new date/time the specified number of months ago.
- def prev_month(months = 1)
- advance(months: -months)
- end
-
# Short-hand for months_ago(1).
def last_month
months_ago(1)
@@ -249,11 +224,6 @@ module DateAndTime
end
alias_method :last_quarter, :prev_quarter
- # Returns a new date/time the specified number of years ago.
- def prev_year(years = 1)
- advance(years: -years)
- end
-
# Short-hand for years_ago(1).
def last_year
years_ago(1)
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