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

Method parseWeeklyBase

pkg/parser/schedule_parser.go:424–451  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

422}
423
424func (p *ScheduleParser) parseWeeklyBase() (string, error) {
425 scheduleLog.Printf("Parsing weekly schedule: token_count=%d", len(p.tokens))
426 if len(p.tokens) == 1 {
427 return "FUZZY:WEEKLY * * *", nil
428 }
429 if len(p.tokens) < 3 || p.tokens[1] != "on" {
430 return "", errors.New("weekly schedule requires 'on <weekday>' or use 'weekly' alone for fuzzy schedule")
431 }
432
433 weekdayStr := p.tokens[2]
434 weekday := mapWeekday(weekdayStr)
435 if weekday == "" {
436 return "", fmt.Errorf("invalid weekday '%s'", weekdayStr)
437 }
438 if len(p.tokens) == 3 {
439 return fmt.Sprintf("FUZZY:WEEKLY:%s * * *", weekday), nil
440 }
441 if p.tokens[3] != "around" {
442 return "", fmt.Errorf("'weekly on <weekday> at <time>' syntax is not supported. Use fuzzy schedules like 'weekly on %s' (scattered), 'weekly on %s around <time>', or standard cron syntax (e.g., '30 6 * * %s')", weekdayStr, weekdayStr, weekday)
443 }
444
445 timeStr, err := p.extractTime(4)
446 if err != nil {
447 return "", err
448 }
449 minute, hour := parseTime(timeStr)
450 return fmt.Sprintf("FUZZY:WEEKLY_AROUND:%s:%s:%s * * *", weekday, hour, minute), nil
451}
452
453func (p *ScheduleParser) parseNamedFuzzyBase(name, cronExpr string) (string, error) {
454 if len(p.tokens) == 1 {

Callers 1

parseBaseMethod · 0.95

Calls 5

extractTimeMethod · 0.95
mapWeekdayFunction · 0.85
parseTimeFunction · 0.85
PrintfMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected