token = scanner.nextToken();
if (token.id == TimeToken.PLUS || token.id == TimeToken.MINUS) {
break;
}
if (time_reference != TimeToken.NOW) {
throw new RrdException("Words 'start' or 'end' MUST be followed by +|- offset");
}
else if (token.id != TimeToken.EOF) {
throw new RrdException("If 'now' is followed by a token it must be +|- offset");
}
break;
/* Only absolute time specifications below */
case TimeToken.NUMBER:
timeOfDay();
if (token.id != TimeToken.NUMBER) {
break;
}
/* fix month parsing */
case TimeToken.JAN:
case TimeToken.FEB:
case TimeToken.MAR:
case TimeToken.APR:
case TimeToken.MAY:
case TimeToken.JUN:
case TimeToken.JUL:
case TimeToken.AUG:
case TimeToken.SEP:
case TimeToken.OCT:
case TimeToken.NOV:
case TimeToken.DEC:
day();
if (token.id != TimeToken.NUMBER) {
break;
}
timeOfDay();
break;
/* evil coding for TEATIME|NOON|MIDNIGHT - we've initialized
* hr to zero up above, then fall into this case in such a
* way so we add +12 +4 hours to it for teatime, +12 hours
* to it for noon, and nothing at all for midnight, then
* set our rettime to that hour before leaping into the
* month scanner
*/
case TimeToken.TEATIME:
hr += 4;
/* FALLTHRU */
case TimeToken.NOON:
hr += 12;
/* FALLTHRU */
case TimeToken.MIDNIGHT:
spec.hour = hr;
spec.min = 0;
spec.sec = 0;
token = scanner.nextToken();
day();
break;
default:
throw new RrdException("Unparsable time: " + token.value);
}
/*
* the OFFSET-SPEC part
*
* (NOTE, the sc_tokid was prefetched for us by the previous code)
*/
if (token.id == TimeToken.PLUS || token.id == TimeToken.MINUS) {
scanner.setContext(false);
while (token.id == TimeToken.PLUS || token.id == TimeToken.MINUS ||
token.id == TimeToken.NUMBER) {
if (token.id == TimeToken.NUMBER) {
plusMinus(PREVIOUS_OP);
}
else {
plusMinus(token.id);
}
token = scanner.nextToken();
/* We will get EOF eventually but that's OK, since
token() will return us as many EOFs as needed */
}
}
/* now we should be at EOF */
if (token.id != TimeToken.EOF) {
throw new RrdException("Unparsable trailing text: " + token.value);
}
return spec;
}