shogi-server source
Révision | 457848cef7fa6fa068cb1d28c25119ff85101a6b (tree) |
---|---|
l'heure | 2012-12-30 17:24:33 |
Auteur | Daigo Moriwaki <beatles@user...> |
Commiter | Daigo Moriwaki |
Backported 87d145bd1f1a14a33f5f6fbc78b63a1952f1ca90 and 2df8c798aeb7f0e77735e893fd1370c2c6f15c4d:
@@ -4,6 +4,11 @@ | ||
4 | 4 | - Backported a5c94012656902e73e00f46e7a4c7004b24d4578: |
5 | 5 | test/TC_logger.rb depeneded on a specific directory where it was |
6 | 6 | 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. | |
7 | 12 | |
8 | 13 | 2012-12-28 Daigo Moriwaki <daigo at debian dot org> |
9 | 14 |
@@ -120,7 +120,7 @@ class League | ||
120 | 120 | next if dow_index.nil? |
121 | 121 | next unless (0..23).include?(hour) |
122 | 122 | 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 | |
124 | 124 | time += 7 if time <= now |
125 | 125 | candidates << time |
126 | 126 | end |
@@ -85,6 +85,11 @@ class TestNextTimeGenerator_900_0 < Test::Unit::TestCase | ||
85 | 85 | now = Time.mktime(2009,12,31,23,50) |
86 | 86 | assert_equal(Time.mktime(2010,1,1,0,0), @next.call(now)) |
87 | 87 | 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 | |
88 | 93 | end |
89 | 94 | |
90 | 95 | class TestNextTimeGenerator_3600_0 < Test::Unit::TestCase |
@@ -126,6 +131,11 @@ class TestNextTimeGenerator_3600_0 < Test::Unit::TestCase | ||
126 | 131 | now = Time.mktime(2009,12,31,23,30) |
127 | 132 | assert_equal(Time.mktime(2010,1,1,1,0), @next.call(now)) |
128 | 133 | 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 | |
129 | 139 | end |
130 | 140 | |
131 | 141 | class TestNextTimeGeneratorConfig < Test::Unit::TestCase |
@@ -153,6 +163,30 @@ class TestNextTimeGeneratorConfig < Test::Unit::TestCase | ||
153 | 163 | assert_equal Time.parse("17-06-2010 20:00"), ntc.call(now) |
154 | 164 | end |
155 | 165 | |
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 | + | |
156 | 190 | def test_read_time |
157 | 191 | now = Time.mktime(2010, 6, 10, 21, 20, 15) |
158 | 192 | ntc = ShogiServer::League::Floodgate::NextTimeGeneratorConfig.new "Thu 22:00" |