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

Function IsWeeklyCron

pkg/parser/schedule_cron_detection.go:90–131  ·  view source on GitHub ↗

IsWeeklyCron checks if a cron expression represents a weekly schedule at a fixed time (e.g., "0 0 * * 1", "30 14 * * 5", etc.)

(cron string)

Source from the content-addressed store, hash-verified

88// IsWeeklyCron checks if a cron expression represents a weekly schedule at a fixed time
89// (e.g., "0 0 * * 1", "30 14 * * 5", etc.)
90func IsWeeklyCron(cron string) bool {
91 fields := strings.Fields(cron)
92 if len(fields) != 5 {
93 return false
94 }
95 // Weekly pattern: minute hour * * DOW
96 // The minute and hour must be specific values (numbers), not wildcards
97 // The day-of-month (3rd field) and month (4th field) must be "*"
98 // The day-of-week (5th field) must be a specific day (0-6)
99
100 // Check if minute and hour are numeric (not wildcards)
101 minute := fields[0]
102 hour := fields[1]
103
104 // Minute and hour should be digits only (no *, /, -, ,)
105 for _, ch := range minute {
106 if ch < '0' || ch > '9' {
107 return false
108 }
109 }
110 for _, ch := range hour {
111 if ch < '0' || ch > '9' {
112 return false
113 }
114 }
115
116 // Check day-of-month and month are wildcards
117 if fields[2] != "*" || fields[3] != "*" {
118 return false
119 }
120
121 // Check day-of-week is a specific day (0-6)
122 dow := fields[4]
123 for _, ch := range dow {
124 if ch < '0' || ch > '6' {
125 return false
126 }
127 }
128
129 cronDetectionLog.Printf("Cron expression classified as weekly: %q (minute=%s, hour=%s, dow=%s)", cron, minute, hour, dow)
130 return true
131}
132
133// IsFuzzyCron checks if a cron expression is a fuzzy schedule placeholder
134func IsFuzzyCron(cron string) bool {

Callers 4

TestIsWeeklyCronFunction · 0.85

Calls 1

PrintfMethod · 0.45

Tested by 2

TestIsWeeklyCronFunction · 0.68