MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / parse_cron_expression

Function parse_cron_expression

core/scheduling.py:16–40  ·  view source on GitHub ↗

Parse a 5-part cron expression into its components. Args: cron_expression: A string like "0 3 * * *" Returns: dict with keys: minute, hour, day_of_month, month_of_year, day_of_week Raises: ValueError: If the expression is not valid 5-part cron.

(cron_expression)

Source from the content-addressed store, hash-verified

14
15
16def parse_cron_expression(cron_expression):
17 """
18 Parse a 5-part cron expression into its components.
19
20 Args:
21 cron_expression: A string like "0 3 * * *"
22
23 Returns:
24 dict with keys: minute, hour, day_of_month, month_of_year, day_of_week
25
26 Raises:
27 ValueError: If the expression is not valid 5-part cron.
28 """
29 parts = cron_expression.strip().split()
30 if len(parts) != 5:
31 raise ValueError(
32 "Cron expression must have 5 parts: minute hour day month weekday"
33 )
34 return {
35 "minute": parts[0],
36 "hour": parts[1],
37 "day_of_month": parts[2],
38 "month_of_year": parts[3],
39 "day_of_week": parts[4],
40 }
41
42
43def create_or_update_periodic_task(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected