Sha256: 1fc7ee886c570fd415a9ce07cc6414eb8d498deb069a6b0228d38654a75de20a
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
class Time class << self def log_elapsed(message = nil, &block) timer = Time.now result = block.call message = "#{message} (#{timer.elapsed.microseconds}ms)" puts message Quandl::Logger.info(message) result end def elapsed(message = nil, &block) log_elapsed(message, &block) end end def week_from_beginning_to_end (beginning_of_week..end_of_week) end def this_week? week_from_beginning_to_end.cover?(Time.now) end def month_from_beginning_to_end (beginning_of_month..end_of_month) end def this_month? month_from_beginning_to_end.cover?(Time.now) end def round(seconds = 60) Time.at((to_f / seconds).round * seconds) end def floor(seconds = 60) Time.at((to_f / seconds).floor * seconds) end def microseconds (to_f * 1000.0).to_i end def self.elapsed(message = nil, &block) timer = Time.now result = block.call puts "#{message} (#{timer.elapsed.microseconds}ms)" result end def elapsed elapsed_since(Time.now) end def elapsed_since(time) time - self end def elapsed_ms "#{elapsed.microseconds}ms" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
quandl_operation-0.4.2 | lib/quandl/operation/core_ext/time.rb |
quandl_operation-0.4.2.rc1 | lib/quandl/operation/core_ext/time.rb |