{
useByoyomi = true;
preByoyomi = parseTime(s.substring(0, idx));
int idx2 = s.indexOf('/');
if (idx2 <= idx)
throw new ErrorMessage("Invalid time specification");
byoyomi = parseTime(s.substring(idx + 1, idx2));
try
{
byoyomiMoves = Integer.parseInt(s.substring(idx2 + 1));
}
catch (NumberFormatException e)
{
throw new ErrorMessage("Invalid specification for byoyomi"
+ " moves");
}
}
if (preByoyomi <= 0)
throw new ErrorMessage("Pre-byoyomi time must be positive");
if (useByoyomi)
{
if (byoyomi <= 0)
throw new ErrorMessage("Byoyomi time must be positive");
if (byoyomiMoves <= 0)
throw new ErrorMessage("Byoyomi moves must be positive");
return new TimeSettings(preByoyomi, byoyomi, byoyomiMoves);
}
else
return new TimeSettings(preByoyomi);
}