Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions lib/logger/period.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ module Period
def next_rotate_time(now, shift_age)
case shift_age
when 'daily', :daily
t = Time.mktime(now.year, now.month, now.mday) + SiD
t = Time.mktime(now.year, now.month, now.mday, 12) + SiD
return Time.mktime(t.year, t.month, t.mday)
when 'weekly', :weekly
t = Time.mktime(now.year, now.month, now.mday) + SiD * (7 - now.wday)
t = Time.mktime(now.year, now.month, now.mday, 12) + SiD * (7 - now.wday)
return Time.mktime(t.year, t.month, t.mday)
when 'monthly', :monthly
t = Time.mktime(now.year, now.month, 1) + SiD * 32
return Time.mktime(t.year, t.month, 1)
Expand All @@ -20,12 +22,6 @@ def next_rotate_time(now, shift_age)
else
raise ArgumentError, "invalid :shift_age #{shift_age.inspect}, should be daily, weekly, monthly, or everytime"
end
if t.hour.nonzero? or t.min.nonzero? or t.sec.nonzero?
hour = t.hour
t = Time.mktime(t.year, t.month, t.mday)
t += SiD if hour > 12
end
t
end

def previous_period_end(now, shift_age)
Expand Down