def time_duration(mytime, start_time, end_time)
t = end_time - start_time
- if @byoyomi > 0
- # If the remaining thinking time covers the duration t, floor it.
- if mytime + @byoyomi - t > 0
- t = t.floor
- else
- t = t.ceil
- end
- else
- # Thinking time only
- t = t.floor
- end
-
- return t
+ return t.floor
end
def to_s
assert_equal(0, tc.time_duration(100, 100.1, 100.9)) # 0.8
assert_equal(1, tc.time_duration(100, 100, 101)) # 1
assert_equal(1, tc.time_duration(100, 100.1, 101.9)) # 1.8
- assert_equal(1, tc.time_duration(1, 100, 101)) # 1
+ assert_equal(1, tc.time_duration(1, 100, 101)) # 1
assert_equal(2, tc.time_duration(100, 100.1, 102.9)) # 2.8
assert_equal(2, tc.time_duration(100, 100, 102)) # 2
end