diff --git a/src/cronparse/describer.py b/src/cronparse/describer.py new file mode 100644 index 0000000..048eeb9 --- /dev/null +++ b/src/cronparse/describer.py @@ -0,0 +1,23 @@ +"""Cron expression description module using cron-descriptor.""" + +from typing import Optional +from cron_descriptor import Options, DescriptionTypeEnum + + +def describe_cron(expression: str, use_24h: bool = False) -> str: + """Describe a cron expression in human-readable language. + + Args: + expression: The cron expression. + use_24h: Whether to use 24-hour time format. + + Returns: + Human-readable description of the cron expression. + """ + options = Options() + options.use_24hour_time_format = use_24h + options.description_type = DescriptionTypeEnum.FULL + + from cron_descriptor import get_description + description = get_description(expression, options) + return description