Sha256: 4d059ff88d4e369d5dc6a2fcc4d08d4803bd2869895aa392129dbe7431ba8015
Contents?: true
Size: 364 Bytes
Versions: 10
Compression:
Stored size: 364 Bytes
Contents
require 'facets/time/trunc' class Time # Round time at the nearest range (in seconds). # # t1 = Time.now # t2 = t1.round_to(60*60) # t2.min #=> 0 # t2.sec #=> 0 # # TODO: What about `round(:minute)`? # # TODO: Fractional seconds should round the usec. # def round_to(seconds) (self + seconds / 2.0).trunc(seconds) end end
Version data entries
10 entries across 9 versions & 2 rubygems