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
103
104
//! A cron expression parser and schedule explorer built with `jiff`.
//!
//! # Examples
//!
//! ```rust
//! use std::str::FromStr;
//!
//! use jiff_cron::{jiff::tz::TimeZone, Schedule};
//!
//! fn main() {
//! // sec min hour day of month month day of week year
//! let expression = "0 30 9,12,15 1,15 May-Aug Mon,Wed,Fri 2018/2";
//! let schedule = Schedule::from_str(expression).unwrap();
//! println!("Upcoming fire times:");
//! for datetime in schedule.upcoming(TimeZone::UTC).take(10) {
//! println!("→ {}", datetime);
//! }
//! }
//!
//! /*
//!
//! Upcoming fire times:
//!
//! → 2018-06-01T09:30:00+00:00[UTC]
//! → 2018-06-01T12:30:00+00:00[UTC]
//! → 2018-06-01T15:30:00+00:00[UTC]
//! → 2018-06-15T09:30:00+00:00[UTC]
//! → 2018-06-15T12:30:00+00:00[UTC]
//! → 2018-06-15T15:30:00+00:00[UTC]
//! → 2018-08-01T09:30:00+00:00[UTC]
//! → 2018-08-01T12:30:00+00:00[UTC]
//! → 2018-08-01T15:30:00+00:00[UTC]
//! → 2018-08-15T09:30:00+00:00[UTC]
//!
//! */
//! ```
//!
//! ## DST behavior
//!
//! `jiff` also handles daylight savings gaps and folding appropriately:
//!
//! ```rust
//! use std::str::FromStr;
//!
//! use jiff_cron::{
//! jiff::{civil::date, tz::TimeZone},
//! Schedule,
//! };
//!
//! fn main() {
//! let expression = "0 0 * * * * *";
//! let schedule = Schedule::from_str(expression).unwrap();
//! let after_datetime = date(2022, 11, 5)
//! .at(23, 30, 0, 0)
//! .in_tz("America/Chicago")
//! .unwrap();
//! println!("Upcoming fire times:");
//! for datetime in schedule.after(after_datetime).take(5) {
//! println!("→ {}", datetime);
//! }
//! }
//!
//! /*
//!
//! Upcoming fire times:
//!
//! → 2022-11-06T00:00:00-05:00[America/Chicago]
//! → 2022-11-06T01:00:00-05:00[America/Chicago]
//! → 2022-11-06T01:00:00-06:00[America/Chicago]
//! → 2022-11-06T02:00:00-06:00[America/Chicago]
//! → 2022-11-06T03:00:00-06:00[America/Chicago]
//!
//! */
//! ```
//!
//! # Installation
//!
//! Add to your `Cargo.toml`:
//!
//! ```toml
//! jiff-cron = "0.3.0"
//! ```
//!
//! You can enable optional [`serde`](https://docs.rs/crate/serde) support
//! via [crate feature toggle](https://docs.rs/crate/jiff-cron/latest/features).
/// Error types used by this crate.
pub use jiff;
pub use crate::;