From be5de490906e1b2b542ba6e0160672f92a24ab60 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 21 Feb 2014 07:45:55 +0000 Subject: logger.rb: DST * lib/logger.rb (next_rotate_time, previous_period_end): consider DST change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/logger.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'lib/logger.rb') diff --git a/lib/logger.rb b/lib/logger.rb index ef9c75d068..ca667f48b4 100644 --- a/lib/logger.rb +++ b/lib/logger.rb @@ -714,29 +714,26 @@ private when /^monthly$/ t = Time.mktime(now.year, now.month, 1) + SiD * 31 mday = (1 if t.mday > 1) - if mday - t = Time.mktime(t.year, t.month, mday) - end else return now end + if mday or t.hour.nonzero? or t.min.nonzero? or t.sec.nonzero? + t = Time.mktime(t.year, t.month, mday || (t.mday + (t.hour > 12 ? 1 : 0))) + end t end def previous_period_end(now, shift_age) case shift_age when /^daily$/ - eod(now - 1 * SiD) + t = Time.mktime(now.year, now.month, now.mday) - SiD / 2 when /^weekly$/ - eod(now - ((now.wday + 1) * SiD)) + t = Time.mktime(now.year, now.month, now.mday) - (SiD * (now.wday + 1) + SiD / 2) when /^monthly$/ - eod(now - now.mday * SiD) + t = Time.mktime(now.year, now.month, 1) - SiD / 2 else - now + return now end - end - - def eod(t) Time.mktime(t.year, t.month, t.mday, 23, 59, 59) end end -- cgit v1.2.3