Crates.io | english-to-cron |
lib.rs | english-to-cron |
version | |
source | src |
created_at | 2024-09-11 07:32:44.282066+00 |
updated_at | 2025-03-02 07:11:22.936391+00 |
description | converts natural language into cron expressions |
homepage | https://docs.rs/english-to-cron |
repository | https://github.com/kaplanelad/english-to-cron |
max_upload_size | |
id | 1371651 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
This project is inspired by the library natural-cron, which converts natural language into cron expressions. english-to-cron
brings similar functionality to the Rust ecosystem, allowing developers to easily schedule cron jobs using English text.
Add the following line to your Cargo.toml
under [dependencies]
:
english_to_cron = "0.1"
Simply provide an English phrase describing the schedule, and the library will return the corresponding cron job syntax.
use english_to_cron::str_cron_syntax;
fn main() {
assert_eq!(str_cron_syntax("every 15 seconds").unwrap(), "0/15 * * * * ? *");
assert_eq!(str_cron_syntax("every minute").unwrap(), "0 * * * * ? *");
assert_eq!(str_cron_syntax("every day at 4:00 pm").unwrap(), "0 0 16 */1 * ? *");
assert_eq!(str_cron_syntax("at 10:00 am").unwrap(), "0 0 10 * * ? *");
assert_eq!(str_cron_syntax("Run at midnight on the 1st and 15th of the month").unwrap(), "0 0 0 1,15 * ? *");
assert_eq!(str_cron_syntax("on Sunday at 12:00").unwrap(), "0 0 12 ? * SUN *");
}
English Phrase | CronJob Syntax |
---|---|
every 15 seconds | 0/15 * * * * ? * |
run every minute | 0 * * * * ? * |
fire every day at 4:00 pm | 0 0 16 */1 * ? * |
at 10:00 am | 0 0 10 * * ? * |
run at midnight on the 1st and 15th of the month | 0 0 0 1,15 * ? * |
On Sunday at 12:00 | 0 0 12 ? * SUN * |
7pm every Thursday | 0 0 19 ? * THU * |
midnight on Tuesdays | 0 0 ? * TUE * |
Contributions are welcome! Feel free to open issues or submit pull requests to help improve the library.