ruby-changes:40211
From: nobu <ko1@a...>
Date: Mon, 26 Oct 2015 23:51:50 +0900 (JST)
Subject: [ruby-changes:40211] nobu:r52292 (trunk): logger.rb: exact matching
nobu 2015-10-26 23:51:39 +0900 (Mon, 26 Oct 2015) New Revision: 52292 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52292 Log: logger.rb: exact matching * lib/logger.rb ({next,previous}_rotate_time): dispatch by exact matching shift_age instead of regexp matching. Modified files: trunk/lib/logger.rb Index: lib/logger.rb =================================================================== --- lib/logger.rb (revision 52291) +++ lib/logger.rb (revision 52292) @@ -533,11 +533,11 @@ private https://github.com/ruby/ruby/blob/trunk/lib/logger.rb#L533 def next_rotate_time(now, shift_age) case shift_age - when /^daily$/ + when 'daily' t = Time.mktime(now.year, now.month, now.mday) + SiD - when /^weekly$/ + when 'weekly' t = Time.mktime(now.year, now.month, now.mday) + SiD * (7 - now.wday) - when /^monthly$/ + when 'monthly' t = Time.mktime(now.year, now.month, 1) + SiD * 31 mday = (1 if t.mday > 1) else @@ -551,11 +551,11 @@ private https://github.com/ruby/ruby/blob/trunk/lib/logger.rb#L551 def previous_period_end(now, shift_age) case shift_age - when /^daily$/ + when 'daily' t = Time.mktime(now.year, now.month, now.mday) - SiD / 2 - when /^weekly$/ + when 'weekly' t = Time.mktime(now.year, now.month, now.mday) - (SiD * (now.wday + 1) + SiD / 2) - when /^monthly$/ + when 'monthly' t = Time.mktime(now.year, now.month, 1) - SiD / 2 else return now -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/