Sha256: a9d90f0c9deebbc5606cd125540a1fbba11778632db72337b9cbd64376314af5

Contents?: true

Size: 694 Bytes

Versions: 10

Compression:

Stored size: 694 Bytes

Contents

class Time

  # Uses Date to provide precise Time calculations for years, months, and days.
  # The +options+ parameter 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>.
  #
  # CREDIT: ActiveSupport Team

  def advance(options)
    d = to_date.advance(options)
    time_advanced_by_date = change(:year => d.year, :month => d.month, :day => d.day)
    seconds_to_advance = (options[:seconds] || 0) + (options[:minutes] || 0) * 60 + (options[:hours] || 0) * 3600
    seconds_to_advance == 0 ? time_advanced_by_date : time_advanced_by_date.since(seconds_to_advance)
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/time/advance.rb
facets-2.8.3 lib/core/facets/time/advance.rb
facets-2.8.2 lib/core/facets/time/advance.rb
facets-2.8.1 lib/core/facets/time/advance.rb
facets-2.8.0 lib/core/facets/time/advance.rb
facets-2.7.0 lib/core/facets/time/advance.rb
facets-2.6.0 lib/core/facets/time/advance.rb
facets-2.5.0 lib/core/facets/time/advance.rb
facets-2.5.1 lib/core/facets/time/advance.rb
facets-2.5.2 lib/core/facets/time/advance.rb