• R/O
  • HTTP
  • SSH
  • HTTPS

shogi-server: Commit

shogi-server source


Commit MetaInfo

Révision457848cef7fa6fa068cb1d28c25119ff85101a6b (tree)
l'heure2012-12-30 17:24:33
AuteurDaigo Moriwaki <beatles@user...>
CommiterDaigo Moriwaki

Message de Log

Backported 87d145bd1f1a14a33f5f6fbc78b63a1952f1ca90 and 2df8c798aeb7f0e77735e893fd1370c2c6f15c4d:

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.

Change Summary

Modification

--- a/changelog
+++ b/changelog
@@ -4,6 +4,11 @@
44 - Backported a5c94012656902e73e00f46e7a4c7004b24d4578:
55 test/TC_logger.rb depeneded on a specific directory where it was
66 running on. This issues has been fixed.
7+ - Backported 87d145bd1f1a14a33f5f6fbc78b63a1952f1ca90 and
8+ 2df8c798aeb7f0e77735e893fd1370c2c6f15c4d:
9+ shogi_server/floodgate.rb: Generating next time around the new
10+ year day by reading configuration files did not work correctly.
11+ This issue has been fixed.
712
813 2012-12-28 Daigo Moriwaki <daigo at debian dot org>
914
--- a/shogi_server/league/floodgate.rb
+++ b/shogi_server/league/floodgate.rb
@@ -120,7 +120,7 @@ class League
120120 next if dow_index.nil?
121121 next unless (0..23).include?(hour)
122122 next unless (0..59).include?(minute)
123- time = DateTime::commercial(now.year, now.cweek, dow_index, hour, minute) rescue next
123+ time = DateTime::commercial(now.cwyear, now.cweek, dow_index, hour, minute) rescue next
124124 time += 7 if time <= now
125125 candidates << time
126126 end
--- a/test/TC_floodgate_next_time_generator.rb
+++ b/test/TC_floodgate_next_time_generator.rb
@@ -85,6 +85,11 @@ class TestNextTimeGenerator_900_0 < Test::Unit::TestCase
8585 now = Time.mktime(2009,12,31,23,50)
8686 assert_equal(Time.mktime(2010,1,1,0,0), @next.call(now))
8787 end
88+
89+ def test_50_min_new_year
90+ now = Time.mktime(2012,1,1,0,0)
91+ assert_equal(Time.mktime(2012,1,1,0,30), @next.call(now))
92+ end
8893 end
8994
9095 class TestNextTimeGenerator_3600_0 < Test::Unit::TestCase
@@ -126,6 +131,11 @@ class TestNextTimeGenerator_3600_0 < Test::Unit::TestCase
126131 now = Time.mktime(2009,12,31,23,30)
127132 assert_equal(Time.mktime(2010,1,1,1,0), @next.call(now))
128133 end
134+
135+ def test_new_year
136+ now = Time.mktime(2012,1,1,0,0)
137+ assert_equal(Time.mktime(2012,1,1,1,0), @next.call(now))
138+ end
129139 end
130140
131141 class TestNextTimeGeneratorConfig < Test::Unit::TestCase
@@ -153,6 +163,30 @@ class TestNextTimeGeneratorConfig < Test::Unit::TestCase
153163 assert_equal Time.parse("17-06-2010 20:00"), ntc.call(now)
154164 end
155165
166+ def test_next_year01
167+ now = DateTime.new(2011, 12, 30, 21, 20, 15) # Fri
168+ ntc = ShogiServer::League::Floodgate::NextTimeGeneratorConfig.new ["Sun 00:00"]
169+ assert_equal Time.parse("01-01-2012 00:00"), ntc.call(now)
170+ ntc = ShogiServer::League::Floodgate::NextTimeGeneratorConfig.new ["Sun 01:00"]
171+ assert_equal Time.parse("01-01-2012 01:00"), ntc.call(now)
172+ end
173+
174+ def test_next_year02
175+ now = DateTime.new(2011, 12, 30, 21, 20, 15) # Fri
176+ ntc = ShogiServer::League::Floodgate::NextTimeGeneratorConfig.new ["Mon 00:00"]
177+ assert_equal Time.parse("02-01-2012 00:00"), ntc.call(now)
178+ ntc = ShogiServer::League::Floodgate::NextTimeGeneratorConfig.new ["Mon 01:00"]
179+ assert_equal Time.parse("02-01-2012 01:00"), ntc.call(now)
180+ end
181+
182+ def test_new_year
183+ now = DateTime.new(2012, 1, 1, 1) # Sun; cwyear=2011, cweek=52
184+ ntc = ShogiServer::League::Floodgate::NextTimeGeneratorConfig.new ["Mon 00:00"]
185+ assert_equal Time.parse("02-01-2012 00:00"), ntc.call(now)
186+ ntc = ShogiServer::League::Floodgate::NextTimeGeneratorConfig.new ["Sat 00:00"]
187+ assert_equal Time.parse("07-01-2012 00:00"), ntc.call(now)
188+ end
189+
156190 def test_read_time
157191 now = Time.mktime(2010, 6, 10, 21, 20, 15)
158192 ntc = ShogiServer::League::Floodgate::NextTimeGeneratorConfig.new "Thu 22:00"
Afficher sur ancien navigateur de dépôt.