@@ -27,27 +27,49 @@ Ensure you have Rust installed on your machine. If not, you can get it from [the
2727
2828Add ` croner ` to your ` Cargo.toml ` dependencies:
2929
30+ ** Please note that croner for Rust is work in progress, and not production ready**
31+
3032``` toml
3133[dependencies ]
32- croner = " 7 .0.5 " # Adjust the version as necessary
34+ croner = " 0 .0.1 " # Adjust the version as necessary
3335```
3436
3537### Usage
3638
3739Here's a quick example to get you started:
3840
41+ ** Note that this example will require you to add the ` chrono ` crate**
42+
3943``` rust
4044use croner :: pattern :: CronPattern ;
45+ use croner :: scheduler :: CronScheduler ;
46+
4147use chrono :: Local ;
4248
4349fn main () {
44- let pattern_str = " 0 30 8 * * *" ; // Every day at 8:30:00
45- let cron_pattern = CronPattern :: new (pattern_str ). expect (" Pattern should be valid" );
50+ let pattern_all = " * * * * * *" ;
51+ let pattern_29th_feb_mon = " 0 18 0 29 2 1" ;
52+
53+ let cron_pattern_all = CronPattern :: new (pattern_all ). unwrap ();
54+ let cron_pattern_29th_feb_mon = CronPattern :: new (pattern_29th_feb_mon ). unwrap ();
55+
56+ let time = Local :: now ();
57+
58+ let matches_all = CronScheduler :: is_time_matching (& cron_pattern_all , & time ). unwrap ();
59+
60+ let next_match_29th_feb_mon = CronScheduler :: find_next_occurrence (& cron_pattern_29th_feb_mon , & time ). unwrap ();
4661
47- let now = Local :: now ();
48- if cron_pattern . is_time_matching (& now ) {
49- println! (" The cron pattern matches the current time!" );
50- }
62+ println! (" Time is: {}" , time );
63+ println! (
64+ " Pattern \ " {}\ " does {}" ,
65+ pattern_all ,
66+ if matches_all { " match" } else { " not match" }
67+ );
68+ println! (
69+ " Pattern \ " {}\ " does occur the next time at {}" ,
70+ pattern_29th_feb_mon ,
71+ next_match_29th_feb_mon
72+ );
5173}
5274```
5375
@@ -67,7 +89,7 @@ We welcome contributions! Please feel free to submit a pull request or open an i
6789
6890## License
6991
70- This project is licensed under the MIT License - see the [ LICENSE.md] ( LICENSE ) file for details.
92+ This project is licensed under the MIT License - see the [ LICENSE.md] ( LICENSE.md ) file for details.
7193
7294## Acknowledgments
7395
0 commit comments