MCPcopy Create free account
hub / github.com/github/gh-aw / extractTimeAfter

Method extractTimeAfter

pkg/parser/schedule_parser.go:534–567  ·  view source on GitHub ↗

extractTimeAfter extracts a time specification from tokens starting at startPos until the end Used for parsing the end time in "between START and END" clauses If hasWeekdaysSuffix is true, excludes the last 2 tokens ("on weekdays")

(startPos int, hasWeekdaysSuffix bool)

Source from the content-addressed store, hash-verified

532// Used for parsing the end time in "between START and END" clauses
533// If hasWeekdaysSuffix is true, excludes the last 2 tokens ("on weekdays")
534func (p *ScheduleParser) extractTimeAfter(startPos int, hasWeekdaysSuffix bool) (string, error) {
535 if startPos >= len(p.tokens) {
536 return "", errors.New("expected time specification")
537 }
538
539 endPos := len(p.tokens)
540 if hasWeekdaysSuffix {
541 endPos -= 2
542 }
543
544 if startPos >= endPos {
545 return "", errors.New("expected time specification")
546 }
547
548 // Collect tokens until endPos (time and optional UTC offset)
549 timeStr := p.tokens[startPos]
550
551 timeTokens := []string{timeStr}
552 nextIndex := startPos + 1
553 if nextIndex < endPos && isAMPMToken(p.tokens[nextIndex]) {
554 timeTokens = append(timeTokens, p.tokens[nextIndex])
555 nextIndex++
556 }
557 if nextIndex < endPos {
558 timezoneToken := strings.ToLower(p.tokens[nextIndex])
559 if strings.HasPrefix(timezoneToken, "utc") {
560 timeTokens = append(timeTokens, timezoneToken)
561 } else if normalized, ok := normalizeTimezoneAbbreviation(timezoneToken); ok {
562 timeTokens = append(timeTokens, normalized)
563 }
564 }
565
566 return normalizeTimeTokens(timeTokens), nil
567}
568
569// hasWeekdaysSuffix checks if "on weekdays" is present at the end of tokens
570func (p *ScheduleParser) hasWeekdaysSuffix() bool {

Callers 1

parseDailyBetweenMethod · 0.95

Calls 4

isAMPMTokenFunction · 0.85
normalizeTimeTokensFunction · 0.85
ToLowerMethod · 0.80

Tested by

no test coverage detected