MCPcopy
hub / github.com/codeaashu/claude-code / parseCronExpression

Function parseCronExpression

src/utils/cron.ts:83–101  ·  view source on GitHub ↗
(expr: string)

Source from the content-addressed store, hash-verified

81 * Returns null if invalid or unsupported syntax.
82 */
83export function parseCronExpression(expr: string): CronFields | null {
84 const parts = expr.trim().split(/\s+/)
85 if (parts.length !== 5) return null
86
87 const expanded: number[][] = []
88 for (let i = 0; i < 5; i++) {
89 const result = expandField(parts[i]!, FIELD_RANGES[i]!)
90 if (!result) return null
91 expanded.push(result)
92 }
93
94 return {
95 minute: expanded[0]!,
96 hour: expanded[1]!,
97 dayOfMonth: expanded[2]!,
98 month: expanded[3]!,
99 dayOfWeek: expanded[4]!,
100 }
101}
102
103/**
104 * Compute the next Date strictly after `from` that matches the cron fields,

Callers 3

validateInputFunction · 0.85
readCronTasksFunction · 0.85
nextCronRunMsFunction · 0.85

Calls 2

expandFieldFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected