Module: Logger::Period

Defined in:
lib/aho/metrics_logger/period.rb

Class Method Summary collapse

Class Method Details

.next_rotate_time(now, shift_age) ⇒ Object



7
8
9
# File 'lib/aho/metrics_logger/period.rb', line 7

def next_rotate_time(now, shift_age)
  now + shift_age.to_i
end

.previous_period_end(now, shift_age) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/aho/metrics_logger/period.rb', line 11

def previous_period_end(now, shift_age)
  # case shift_age
  # when 'daily', :daily
  #   t = Time.mktime(now.year, now.month, now.mday) - SiD / 2
  # when 'weekly', :weekly
  #   t = Time.mktime(now.year, now.month, now.mday) - (SiD * now.wday + SiD / 2)
  # when 'monthly', :monthly
  #   t = Time.mktime(now.year, now.month, 1) - SiD / 2
  # when 'now', 'everytime', :now, :everytime
  #   return now
  # else
  #   raise ArgumentError, "invalid :shift_age #{shift_age.inspect}, should be daily, weekly, monthly, or everytime"
  # end
  # Time.mktime(t.year, t.month, t.mday, 23, 59, 59)
end