diff options
author | Michael Stock <mikeastock@gmail.com> | 2015-08-02 17:09:18 -0700 |
---|---|---|
committer | Michael Stock <mikeastock@gmail.com> | 2015-08-02 17:10:58 -0700 |
commit | 3d038505f1afe4af72e3d2e8acfd75ce804a99f5 (patch) | |
tree | dcfede803c491c5bf1d45b6194109932c8f33388 /activesupport | |
parent | 722abe1722a8bcf1798fc7f7f9a8cf4dcfa28e88 (diff) | |
download | rails-3d038505f1afe4af72e3d2e8acfd75ce804a99f5.tar.gz rails-3d038505f1afe4af72e3d2e8acfd75ce804a99f5.tar.bz2 rails-3d038505f1afe4af72e3d2e8acfd75ce804a99f5.zip |
[ci skip] Update Time#advance documentation with examples
Diffstat (limited to 'activesupport')
-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) |