chore: auto-commit (286 archivos)
- .claude/agents/fn-orquestador/SKILL.md - .claude/commands/fn_claude.md - .claude/rules/INDEX.md - .claude/rules/cpp_apps.md - .claude/rules/ids_naming.md - CHANGELOG.md - apps/dag_engine/README.md - apps/dag_engine/api.go - apps/dag_engine/dags_migrated/example.yaml - apps/dag_engine/dags_migrated/example_lineage_tracking.yaml - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
---
|
||||
name: cron_explain
|
||||
kind: function
|
||||
lang: go
|
||||
domain: core
|
||||
version: "1.0.0"
|
||||
purity: pure
|
||||
signature: "func CronExplain(expr string) string"
|
||||
description: "Convierte una expresion cron (5 campos o shortcut @daily/@hourly/etc.) en una frase humana corta. Reconoce patrones comunes: every N minutes/hours, daily/weekdays at HH:MM, y shortcuts. Devuelve el expr crudo si no encaja en ningun patron. Sin dependencias externas, solo stdlib."
|
||||
tags: ["cron", "scheduler", "humanize"]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: ""
|
||||
imports: ["fmt", "strconv", "strings"]
|
||||
tested: true
|
||||
tests:
|
||||
- "every 15 minutes"
|
||||
- "daily at 00:00"
|
||||
- "weekdays at 09:00"
|
||||
- "every 30 minutes"
|
||||
- "every 2 hours"
|
||||
- "shortcut @hourly"
|
||||
- "shortcut @daily"
|
||||
- "shortcut @weekly"
|
||||
- "shortcut @monthly"
|
||||
- "unknown returns raw"
|
||||
- "invalid too few fields"
|
||||
- "every minute"
|
||||
- "daily at 14:30"
|
||||
- "every hour zero min"
|
||||
- "shortcut @midnight"
|
||||
- "weekdays at 08:00"
|
||||
test_file_path: "functions/core/cron_explain_test.go"
|
||||
file_path: "functions/core/cron_explain.go"
|
||||
params:
|
||||
- name: expr
|
||||
desc: "Expresion cron de 5 campos (min hora dom mes dow) o shortcut (@hourly, @daily, @weekly, @monthly, @yearly). Se ignoran campos extra (6to campo segundos/year)."
|
||||
output: "Frase legible en ingles: 'every N minutes', 'daily at HH:MM', 'weekdays at HH:MM', 'hourly', 'daily', 'weekly', 'monthly'. Devuelve expr sin modificar si el patron no es reconocido."
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```go
|
||||
fmt.Println(CronExplain("*/15 * * * *")) // every 15 minutes
|
||||
fmt.Println(CronExplain("0 0 * * *")) // daily at 00:00
|
||||
fmt.Println(CronExplain("0 9 * * 1-5")) // weekdays at 09:00
|
||||
fmt.Println(CronExplain("*/30 * * * *")) // every 30 minutes
|
||||
fmt.Println(CronExplain("0 */2 * * *")) // every 2 hours
|
||||
fmt.Println(CronExplain("@hourly")) // hourly
|
||||
fmt.Println(CronExplain("5 4 * * 0")) // 5 4 * * 0 (not recognized, returned raw)
|
||||
```
|
||||
|
||||
## Cuando usarla
|
||||
|
||||
Cuando necesites mostrar al usuario una descripcion legible de un schedule cron en una UI, log o CLI. Antes de renderizar un campo `cron_expr` en un dashboard o TUI.
|
||||
|
||||
## Gotchas
|
||||
|
||||
Funcion pura — nunca falla ni entra en panico. Patrones reconocidos son los comunes; expresiones con listas (`1,3,5`), rangos en horas, o combinaciones complejas devuelven el expr crudo sin error.
|
||||
Reference in New Issue
Block a user