1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//! # cronspeak — say cron out loud
//!
//! Convert cron expressions into clear, human-readable English, the way
//! [`cronstrue`] (JavaScript) and [`cron-descriptor`] (Python) do.
//!
//! ```
//! assert_eq!(
//! cronspeak::describe("0 9 * * 1-5").unwrap(),
//! "At 09:00 AM, Monday through Friday"
//! );
//! assert_eq!(cronspeak::describe("*/15 * * * *").unwrap(), "Every 15 minutes");
//! assert_eq!(cronspeak::describe("@daily").unwrap(), "At 12:00 AM");
//! ```
//!
//! Pure logic, zero dependencies, `#![no_std]` (needs only `alloc`).
//!
//! ## Supported syntax
//!
//! Standard 5-field cron (`minute hour day-of-month month day-of-week`) with
//! `*`, single values, lists (`a,b`), ranges (`a-b`), and steps (`*/n`, `a-b/n`,
//! `a/n`). Month and day-of-week accept names (`JAN`…`DEC`, `SUN`…`SAT`,
//! case-insensitive). The macros `@yearly`/`@annually`, `@monthly`, `@weekly`,
//! `@daily`/`@midnight`, and `@hourly` are also recognized.
//!
//! [`cronstrue`]: https://github.com/bradymholt/cRonstrue
//! [`cron-descriptor`]: https://pypi.org/project/cron-descriptor/
extern crate alloc;
use String;
pub use CronError;
/// Clock style used when rendering times of day.
/// Options controlling how a cron expression is described.
/// Describe a cron expression in human-readable English using default options.
///
/// ```
/// assert_eq!(cronspeak::describe("0 0 1 * *").unwrap(), "At 12:00 AM, on day 1 of the month");
/// ```
///
/// # Errors
///
/// Returns [`CronError`] if the expression is empty, has the wrong number of
/// fields, or contains an invalid value, range, or step.
/// Describe a cron expression using the given [`Options`].
///
/// # Errors
///
/// Returns [`CronError`] for the same reasons as [`describe`].