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

Method extractTime

pkg/parser/schedule_parser.go:479–508  ·  view source on GitHub ↗

extractTime extracts the time specification from tokens starting at startPos Returns the time string (HH:MM, midnight, or noon) with optional UTC offset

(startPos int)

Source from the content-addressed store, hash-verified

477// extractTime extracts the time specification from tokens starting at startPos
478// Returns the time string (HH:MM, midnight, or noon) with optional UTC offset
479func (p *ScheduleParser) extractTime(startPos int) (string, error) {
480 if startPos >= len(p.tokens) {
481 return "", errors.New("expected time specification")
482 }
483
484 // Check for "at" keyword
485 if p.tokens[startPos] == "at" {
486 startPos++
487 if startPos >= len(p.tokens) {
488 return "", errors.New("expected time after 'at'")
489 }
490 }
491
492 timeTokens := []string{p.tokens[startPos]}
493 nextIndex := startPos + 1
494 if nextIndex < len(p.tokens) && isAMPMToken(p.tokens[nextIndex]) {
495 timeTokens = append(timeTokens, p.tokens[nextIndex])
496 nextIndex++
497 }
498 if nextIndex < len(p.tokens) {
499 timezoneToken := strings.ToLower(p.tokens[nextIndex])
500 if strings.HasPrefix(timezoneToken, "utc") {
501 timeTokens = append(timeTokens, timezoneToken)
502 } else if normalized, ok := normalizeTimezoneAbbreviation(timezoneToken); ok {
503 timeTokens = append(timeTokens, normalized)
504 }
505 }
506
507 return normalizeTimeTokens(timeTokens), nil
508}
509
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

Callers 2

parseWeeklyBaseMethod · 0.95

Calls 4

isAMPMTokenFunction · 0.85
normalizeTimeTokensFunction · 0.85
ToLowerMethod · 0.80

Tested by

no test coverage detected