From 3d038505f1afe4af72e3d2e8acfd75ce804a99f5 Mon Sep 17 00:00:00 2001 From: Michael Stock Date: Sun, 2 Aug 2015 17:09:18 -0700 Subject: [ci skip] Update Time#advance documentation with examples --- activesupport/lib/active_support/core_ext/time/calculations.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activesupport/lib/active_support/core_ext/time/calculations.rb') 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: :years, :months, # :weeks, :days, :hours, :minutes, # :seconds. + # + # 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) -- cgit v1.2.3