{"id":13838473,"url":"https://github.com/nbari/cron-parser","last_synced_at":"2025-04-09T11:11:52.113Z","repository":{"id":35793150,"uuid":"219318770","full_name":"nbari/cron-parser","owner":"nbari","description":"cron parser","archived":false,"fork":false,"pushed_at":"2024-12-13T23:02:34.000Z","size":88,"stargazers_count":24,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T09:11:12.493Z","etag":null,"topics":["cron","cron-expression","cron-format","cron-parser","crontab","crontab-expressions","parser"],"latest_commit_sha":null,"homepage":"https://docs.rs/cron-parser/latest/cron_parser/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nbari.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"nbari"}},"created_at":"2019-11-03T15:05:48.000Z","updated_at":"2025-01-20T15:18:23.000Z","dependencies_parsed_at":"2024-01-15T19:43:32.586Z","dependency_job_id":"235831c1-2716-4cb3-8ec3-2fccdfe352f2","html_url":"https://github.com/nbari/cron-parser","commit_stats":{"total_commits":53,"total_committers":2,"mean_commits":26.5,"dds":"0.018867924528301883","last_synced_commit":"69aa0d519d94d55e972c7438cf508ddb04cbe286"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbari%2Fcron-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbari%2Fcron-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbari%2Fcron-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbari%2Fcron-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nbari","download_url":"https://codeload.github.com/nbari/cron-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248027411,"owners_count":21035594,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cron","cron-expression","cron-format","cron-parser","crontab","crontab-expressions","parser"],"created_at":"2024-08-04T15:01:58.739Z","updated_at":"2025-04-09T11:11:52.093Z","avatar_url":"https://github.com/nbari.png","language":"Rust","readme":"# cron parser\n\n[![crates.io](https://img.shields.io/crates/v/cron-parser.svg)](https://crates.io/crates/cron-parser)\n[![Test](https://github.com/nbari/cron-parser/actions/workflows/test.yml/badge.svg)](https://github.com/nbari/cron-parser/actions/workflows/test.yml)\n[![docs](https://docs.rs/cron-parser/badge.svg)](https://docs.rs/cron-parser)\n\nLibrary for parsing cron expressions with timezone support.\n\nExample:\n\n    use chrono::{TimeZone, Utc};\n    use chrono_tz::Europe::Lisbon;\n    use cron_parser::parse;\n\n    fn main() {\n       if let Ok(next) = parse(\"*/5 * * * *\", \u0026Utc::now()) {\n            println!(\"when: {}\", next);\n       }\n\n       // passing a custom timestamp\n       if let Ok(next) = parse(\"0 0 29 2 *\", \u0026Utc.timestamp(1893456000, 0)) {\n            println!(\"next leap year: {}\", next);\n            assert_eq!(next.timestamp(), 1961625600);\n       }\n\n       assert!(parse(\"2-3,9,*/15,1-8,11,9,4,5 * * * *\", \u0026Utc::now()).is_ok());\n       assert!(parse(\"* * * * */Fri\", \u0026Utc::now()).is_err());\n\n       // use custom timezone\n       assert!(parse(\"*/5 * * * *\", \u0026Utc::now().with_timezone(\u0026Lisbon)).is_ok());\n    }\n\n\nCron table:\n\n```\n# ┌─────────────────────  minute (0 - 59)\n# │ ┌───────────────────  hour   (0 - 23)\n# │ │ ┌─────────────────  dom    (1 - 31) day of month\n# │ │ │ ┌───────────────  month  (1 - 12)\n# │ │ │ │ ┌─────────────  dow    (0 - 6 or Sun - Sat)  day of week (Sunday to Saturday)\n# │ │ │ │ │\n# │ │ │ │ │\n# │ │ │ │ │\n# * * * * * \u003ccommand to execute\u003e\n```\n\n| Field        | Required | Allowed values | Allowed special characters |\n| ------------ | -------- | -------------- | -------------------------- |\n| Minutes      | Yes      | 0–59           | \\* , - /                   |\n| Hours        | Yes      | 0–23           | \\* , - /                   |\n| Day of month | Yes      | 1–31           | \\* , - /                   |\n| Month        | Yes      | 1–12           | \\* , - /                   |\n| Day of week  | Yes      | 0–6 or Sun-Sat | \\* , - /                   |\n\n\u003e For the day of the week, when using a Weekday (Sun-Sat) the expression `*/Day` is not supported instead\n\u003e use the integer, reasons for this is that for example `*/Wed` = `*/3` translates\n\u003e to run every 3rd day of week, this means Sunday, Wednesday, Saturday.\n\n* `*` any value\n* `,` value list separator\n* `-` range of values\n* `/` step values\n\n\n## start-end/step\n\nRanges with steps are supported, for example:\n\n```\n0 12-18/3 * * *  # every 3 hours starting from 12 to 18\n```\n\nOr every 6 hours starting from 1:\n\n```\n0 1/6 * * *\n```\n\n\nDepends on crate [chrono](https://crates.io/crates/chrono).\n\nExample of `Cargo.toml`:\n\n    [dependencies]\n    chrono = \"^0.4\"\n    cron-parser = \"*\"\n\n\nGetting the next 10 leap year iterations:\n\n    use chrono::{DateTime, Utc};\n    use cron_parser::parse;\n\n    fn main() {\n        let now = Utc::now();\n        let mut crons = Vec::\u003cDateTime\u003cUtc\u003e\u003e::new();\n        let mut next = parse(\"0 0 29 2 *\", \u0026now).unwrap();\n        for _ in 0..10 {\n            next = parse(\"0 0 29 2 *\", \u0026next).unwrap();\n            crons.push(next);\n        }\n        for x in crons {\n            println!(\"{} - {}\", x, x.timestamp());\n        }\n    }\n\nIt will print something like:\n\n    2024-02-29 00:00:00 UTC - 1709164800\n    2028-02-29 00:00:00 UTC - 1835395200\n    2032-02-29 00:00:00 UTC - 1961625600\n    2036-02-29 00:00:00 UTC - 2087856000\n    2040-02-29 00:00:00 UTC - 2214086400\n    2044-02-29 00:00:00 UTC - 2340316800\n    2048-02-29 00:00:00 UTC - 2466547200\n    2052-02-29 00:00:00 UTC - 2592777600\n    2056-02-29 00:00:00 UTC - 2719008000\n    2060-02-29 00:00:00 UTC - 2845238400\n","funding_links":["https://github.com/sponsors/nbari"],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnbari%2Fcron-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnbari%2Fcron-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnbari%2Fcron-parser/lists"}