OSDN Git Service

shogi_server/floodgate.rb: Generating next time around the new year day by reading...
authorDaigo Moriwaki <beatles@users.sourceforge.jp>
Sun, 1 Jan 2012 07:07:07 +0000 (16:07 +0900)
committerDaigo Moriwaki <daigo@debian.org>
Sun, 1 Jan 2012 07:07:07 +0000 (16:07 +0900)
changelog
shogi_server/league/floodgate.rb
test/TC_floodgate_next_time_generator.rb

index 430ca72..7e4e6e8 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,3 +1,10 @@
+2012-01-01  Daigo Moriwaki <daigo at debian dot org>
+
+       * [shogi-server]
+         - shogi_server/floodgate.rb: Generating next time around the new
+           year day by reading configuration files did not work correctly.
+           This issue has been fixed.
+
 2011-12-18  Daigo Moriwaki <daigo at debian dot org>
 
        * [sohgi-server]
index f721d3a..b5478b9 100644 (file)
@@ -120,7 +120,7 @@ class League
             next if dow_index.nil?
             next unless (0..23).include?(hour)
             next unless (0..59).include?(minute)
-            time = DateTime::commercial(now.year, now.cweek, dow_index, hour, minute) rescue next
+            time = DateTime::commercial(now.cwyear, now.cweek, dow_index, hour, minute) rescue next
             time += 7 if time <= now 
             candidates << time
           end
index 0a0da4e..2388634 100644 (file)
@@ -179,6 +179,14 @@ class TestNextTimeGeneratorConfig < Test::Unit::TestCase
     assert_equal Time.parse("02-01-2012 01:00"), ntc.call(now)
   end
 
+  def test_new_year
+    now = DateTime.new(2012, 1, 1, 1) # Sun; cwyear=2011, cweek=52
+    ntc = ShogiServer::League::Floodgate::NextTimeGeneratorConfig.new ["Mon 00:00"]
+    assert_equal Time.parse("02-01-2012 00:00"), ntc.call(now)
+    ntc = ShogiServer::League::Floodgate::NextTimeGeneratorConfig.new ["Sat 00:00"]
+    assert_equal Time.parse("07-01-2012 00:00"), ntc.call(now)
+  end
+
   def test_read_time
     now = Time.mktime(2010, 6, 10, 21, 20, 15)
     ntc = ShogiServer::League::Floodgate::NextTimeGeneratorConfig.new ["Thu 22:00"]