Skip to content

Commit 602696a

Browse files
committed
Cleanup
1 parent 35c4b58 commit 602696a

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
name = "croner"
33
version = "0.0.1"
44
edition = "2021"
5+
license = "MIT"
6+
description = "A cron parser and job scheduler library for Rust"
7+
repository = "https://github.com/hexagon/croner-rust"
8+
documentation = "https://docs.rs/croner"
9+
readme = "README.md"
10+
keywords = ["cron", "scheduler", "job", "task", "time"]
11+
categories = ["date-and-time", "scheduling"]
12+
homepage = "https://github.com/hexagon/croner-rust"
513

614
[lib]
715
name = "croner"

README.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,49 @@ Ensure you have Rust installed on your machine. If not, you can get it from [the
2727

2828
Add `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

3739
Here'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
4044
use croner::pattern::CronPattern;
45+
use croner::scheduler::CronScheduler;
46+
4147
use chrono::Local;
4248

4349
fn 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

Comments
 (0)