Sha256: 39e28c900412e36e006f7944192791310f534a28646ab6b47f193a812e10a721

Contents?: true

Size: 236 Bytes

Versions: 15

Compression:

Stored size: 236 Bytes

Contents

require 'facets/time/trunc'

class Time

  # Round time at the nearest range (in seconds).
  #
  #   t = Time.now
  #   =>
  #   t.round(60*60) # 1 hour
  #   =>
  #  
  def round(amount)
    (self+amount/2.0).trunc(amount)
  end

end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
facets-2.8.4 lib/core/facets/time/round.rb
facets-2.8.3 lib/core/facets/time/round.rb
facets-2.8.2 lib/core/facets/time/round.rb
facets-2.8.1 lib/core/facets/time/round.rb
facets-2.8.0 lib/core/facets/time/round.rb
facets-2.7.0 lib/core/facets/time/round.rb
facets-2.6.0 lib/core/facets/time/round.rb
facets-2.4.4 lib/core/facets/time/round.rb
facets-2.4.3 lib/core/facets/time/round.rb
facets-2.4.2 lib/core/facets/time/round.rb
facets-2.4.5 lib/core/facets/time/round.rb
facets-2.5.0 lib/core/facets/time/round.rb
facets-2.5.1 lib/core/facets/time/round.rb
facets-2.5.2 lib/core/facets/time/round.rb
mack-facets-0.8.2 lib/gems/facets-2.4.5/lib/core/facets/time/round.rb