+ TimeControlParams = Struct.new(:total_time, :byoyomi, :fischer, :stop_watch, :error)
+
+ # Parse time related parts of a game name.
+ #
+ # Return an array of a total allotted time, byoyomi seconds and fischer
+ # seconds; if it fails to parse, return nil.
+ def Game.parse_time(game_name)
+ ret = TimeControlParams.new(0, 0, 0, false, false)
+
+ if (game_name =~ /-(\d+)-(\d+F?)$/)
+ ret[:total_time] = $1.to_i
+ tmp = $2
+ if tmp =~ /^0\d/
+ ret[:stop_watch] = true
+ end
+ if tmp[-1] == "F"
+ ret[:fischer] = tmp.chop.to_i
+ else
+ ret[:byoyomi] = tmp.to_i
+ end
+ return ret
+ end
+
+ ret[:error] = true
+ return ret
+ end
+