extractTimeBetween extracts a time specification from tokens between startPos and endPos (exclusive) Used for parsing the start time in "between START and END" clauses
(startPos, endPos int)
| 510 | // extractTimeBetween extracts a time specification from tokens between startPos and endPos (exclusive) |
| 511 | // Used for parsing the start time in "between START and END" clauses |
| 512 | func (p *ScheduleParser) extractTimeBetween(startPos, endPos int) (string, error) { |
| 513 | if startPos >= len(p.tokens) || startPos >= endPos { |
| 514 | return "", errors.New("expected time specification") |
| 515 | } |
| 516 | |
| 517 | // The time is in the tokens between startPos and endPos |
| 518 | // It might be a single token (e.g., "9am") or multiple tokens (e.g., "14:00 utc+9") |
| 519 | timeTokens := []string{} |
| 520 | for i := startPos; i < endPos && i < len(p.tokens); i++ { |
| 521 | timeTokens = append(timeTokens, p.tokens[i]) |
| 522 | } |
| 523 | |
| 524 | if len(timeTokens) == 0 { |
| 525 | return "", errors.New("expected time specification") |
| 526 | } |
| 527 | |
| 528 | return normalizeTimeTokens(timeTokens), nil |
| 529 | } |
| 530 | |
| 531 | // extractTimeAfter extracts a time specification from tokens starting at startPos until the end |
| 532 | // Used for parsing the end time in "between START and END" clauses |
no test coverage detected