diff options
author | Yves Senn <yves.senn@gmail.com> | 2015-08-03 09:46:36 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2015-08-03 09:46:36 +0200 |
commit | ca8f3cac4801e1219b38f575123636436b08129f (patch) | |
tree | fc719da7603bd99674aa80815f7507ef5daa79a0 | |
parent | 31ee9c0036f691f9206da24af1ffd4695b7b157a (diff) | |
parent | 3d038505f1afe4af72e3d2e8acfd75ce804a99f5 (diff) | |
download | rails-ca8f3cac4801e1219b38f575123636436b08129f.tar.gz rails-ca8f3cac4801e1219b38f575123636436b08129f.tar.bz2 rails-ca8f3cac4801e1219b38f575123636436b08129f.zip |
Merge pull request #21103 from mikeastock/update_time_advance_docs
Update Time#advance documentation with examples [ci skip]
-rw-r--r-- | activesupport/lib/active_support/core_ext/time/calculations.rb | 6 |
1 files changed, 6 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 c554501893..96156deebb 100644 --- a/activesupport/lib/active_support/core_ext/time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/time/calculations.rb @@ -108,6 +108,12 @@ class Time # takes a hash with any of these keys: <tt>:years</tt>, <tt>:months</tt>, # <tt>:weeks</tt>, <tt>:days</tt>, <tt>:hours</tt>, <tt>:minutes</tt>, # <tt>:seconds</tt>. + # + # Time.new(2015, 8, 1, 14, 35, 0).advance(seconds: 1) # => 2015-08-01 14:35:01 -0700 + # Time.new(2015, 8, 1, 14, 35, 0).advance(minutes: 1) # => 2015-08-01 14:36:00 -0700 + # Time.new(2015, 8, 1, 14, 35, 0).advance(hours: 1) # => 2015-08-01 15:35:00 -0700 + # Time.new(2015, 8, 1, 14, 35, 0).advance(days: 1) # => 2015-08-02 14:35:00 -0700 + # Time.new(2015, 8, 1, 14, 35, 0).advance(weeks: 1) # => 2015-08-08 14:35:00 -0700 def advance(options) unless options[:weeks].nil? options[:weeks], partial_weeks = options[:weeks].divmod(1) |