summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-21 07:45:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-21 07:45:55 +0000
commitbe5de490906e1b2b542ba6e0160672f92a24ab60 (patch)
treeb508e9afff5614999cb72430f5500a07511bcfcd /lib
parent82d495134c4961d3d6099d1186da978f03bac988 (diff)
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
Diffstat (limited to 'lib')
-rw-r--r--lib/logger.rb17
1 files changed, 7 insertions, 10 deletions
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