diff options
author | Baron Bloomer <[email protected]> | 2022-04-07 12:32:18 +0100 |
---|---|---|
committer | git <[email protected]> | 2024-06-06 09:07:49 +0000 |
commit | d4aff75a454ddfcf039fddb4bccd46087e50f12e (patch) | |
tree | 74cf963a2715f2f67f46dbe8a7692efa4ceec1e5 /lib/logger/period.rb | |
parent | 1a092857955a8ab8b568d465bc82a0efe5f7d052 (diff) |
[ruby/logger] Add support for symbols in #shift_age
Resolves issue: https://github.com/ruby/logger/issues/46
https://github.com/ruby/logger/commit/83502c2107
Diffstat (limited to 'lib/logger/period.rb')
-rw-r--r-- | lib/logger/period.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/logger/period.rb b/lib/logger/period.rb index 0a291dbbbe..a0359defe3 100644 --- a/lib/logger/period.rb +++ b/lib/logger/period.rb @@ -8,14 +8,14 @@ class Logger def next_rotate_time(now, shift_age) case shift_age - when 'daily' + when 'daily', :daily t = Time.mktime(now.year, now.month, now.mday) + SiD - when 'weekly' + when 'weekly', :weekly t = Time.mktime(now.year, now.month, now.mday) + SiD * (7 - now.wday) - when 'monthly' + when 'monthly', :monthly t = Time.mktime(now.year, now.month, 1) + SiD * 32 return Time.mktime(t.year, t.month, 1) - when 'now', 'everytime' + when 'now', 'everytime', :now, :everytime return now else raise ArgumentError, "invalid :shift_age #{shift_age.inspect}, should be daily, weekly, monthly, or everytime" @@ -30,13 +30,13 @@ class Logger def previous_period_end(now, shift_age) case shift_age - when 'daily' + when 'daily', :daily t = Time.mktime(now.year, now.month, now.mday) - SiD / 2 - when 'weekly' + when 'weekly', :weekly t = Time.mktime(now.year, now.month, now.mday) - (SiD * now.wday + SiD / 2) - when 'monthly' + when 'monthly', :monthly t = Time.mktime(now.year, now.month, 1) - SiD / 2 - when 'now', 'everytime' + when 'now', 'everytime', :now, :everytime return now else raise ArgumentError, "invalid :shift_age #{shift_age.inspect}, should be daily, weekly, monthly, or everytime" |