diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-10-24 13:28:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-24 13:28:04 -0400 |
commit | 453ab1758bd57b971f3ecc9f173198e8fac38e1c (patch) | |
tree | 84e45f5c9f3fd48b76ba18ea22e0773a62cf3fa8 /activesupport/lib | |
parent | 4aac0bf66c1d18c23f2096d9a343dbf9a95cbf23 (diff) | |
parent | d86370252ea33c5b6fba2d53efa15b1d0082a487 (diff) | |
download | rails-453ab1758bd57b971f3ecc9f173198e8fac38e1c.tar.gz rails-453ab1758bd57b971f3ecc9f173198e8fac38e1c.tar.bz2 rails-453ab1758bd57b971f3ecc9f173198e8fac38e1c.zip |
Merge pull request #30972 from jcmfernandes/update-core_ext-time-documentation
Make clear that Time core extensions are split between Numeric and Integer
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/integer/time.rb | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/numeric/time.rb | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/core_ext/integer/time.rb b/activesupport/lib/active_support/core_ext/integer/time.rb index 74c73ab064..66160b3dd7 100644 --- a/activesupport/lib/active_support/core_ext/integer/time.rb +++ b/activesupport/lib/active_support/core_ext/integer/time.rb @@ -19,6 +19,8 @@ class Integer # # # equivalent to Time.now.advance(months: 4, years: 5) # (4.months + 5.years).from_now + # + # For other durations, check the extensions to Numeric. def months ActiveSupport::Duration.months(self) end diff --git a/activesupport/lib/active_support/core_ext/numeric/time.rb b/activesupport/lib/active_support/core_ext/numeric/time.rb index d62b57fe27..dee9141356 100644 --- a/activesupport/lib/active_support/core_ext/numeric/time.rb +++ b/activesupport/lib/active_support/core_ext/numeric/time.rb @@ -7,19 +7,21 @@ require "active_support/core_ext/date/calculations" require "active_support/core_ext/date/acts_like" class Numeric - # Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years. + # Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.weeks. # # These methods use Time#advance for precise date calculations when using from_now, ago, etc. # as well as adding or subtracting their results from a Time object. For example: # - # # equivalent to Time.current.advance(months: 1) + # # equivalent to Time.current.advance(days: 1) # 1.month.from_now # - # # equivalent to Time.current.advance(years: 2) - # 2.years.from_now + # # equivalent to Time.current.advance(weeks: 2) + # 2.weeks.from_now # - # # equivalent to Time.current.advance(months: 4, years: 5) - # (4.months + 5.years).from_now + # # equivalent to Time.current.advance(days: 4, weeks: 5) + # (4.days + 5.weeks).from_now + # + # For other durations, check the extensions to Integer. def seconds ActiveSupport::Duration.seconds(self) end |