module Logger::Period

def previous_period_end(now, shift_age)

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