Sha256: 585f004c73bc0efd98686a7707b68d83d60843f4d6af92d33bcd1735ec91c838

Contents?: true

Size: 389 Bytes

Versions: 1

Compression:

Stored size: 389 Bytes

Contents

module TimeExtensions
  %w[ round floor ceil ].each do |_method|
    define_method _method do |*args|
      seconds = args.first || 60
      Time.at((self.to_f / seconds).send(_method) * seconds)
    end
  end

  def end_of_minute
    change(:sec => 59, :usec => 999999.999)
  end

  def beginning_of_minute
    change(:sec => 0, :usec => 0)
  end
end

Time.send :include, TimeExtensions

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redis_analytics-0.1.0 lib/redis_analytics/time_ext.rb