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

Method extractTimeWithWeekdays

pkg/parser/schedule_parser.go:579–613  ·  view source on GitHub ↗

extractTimeWithWeekdays extracts time specification, handling optional "on weekdays" suffix

(startPos int, hasWeekdaysSuffix bool)

Source from the content-addressed store, hash-verified

577
578// extractTimeWithWeekdays extracts time specification, handling optional "on weekdays" suffix
579func (p *ScheduleParser) extractTimeWithWeekdays(startPos int, hasWeekdaysSuffix bool) (string, error) {
580 if startPos >= len(p.tokens) {
581 return "", errors.New("expected time specification")
582 }
583
584 // Check for "at" keyword
585 if p.tokens[startPos] == "at" {
586 startPos++
587 if startPos >= len(p.tokens) {
588 return "", errors.New("expected time after 'at'")
589 }
590 }
591
592 endPos := len(p.tokens)
593 if hasWeekdaysSuffix {
594 endPos -= 2
595 }
596
597 timeTokens := []string{p.tokens[startPos]}
598 nextIndex := startPos + 1
599 if nextIndex < endPos && isAMPMToken(p.tokens[nextIndex]) {
600 timeTokens = append(timeTokens, p.tokens[nextIndex])
601 nextIndex++
602 }
603 if nextIndex < endPos {
604 timezoneToken := strings.ToLower(p.tokens[nextIndex])
605 if strings.HasPrefix(timezoneToken, "utc") {
606 timeTokens = append(timeTokens, timezoneToken)
607 } else if normalized, ok := normalizeTimezoneAbbreviation(timezoneToken); ok {
608 timeTokens = append(timeTokens, normalized)
609 }
610 }
611
612 return normalizeTimeTokens(timeTokens), nil
613}

Callers 1

parseDailyAroundMethod · 0.95

Calls 4

isAMPMTokenFunction · 0.85
normalizeTimeTokensFunction · 0.85
ToLowerMethod · 0.80

Tested by

no test coverage detected