{"id":15468338,"url":"https://github.com/winebarrel/cronplan","last_synced_at":"2025-04-15T01:04:29.299Z","repository":{"id":61629386,"uuid":"552368495","full_name":"winebarrel/cronplan","owner":"winebarrel","description":"Cron expression parser for Amazon EventBridge.","archived":false,"fork":false,"pushed_at":"2024-06-10T19:07:23.000Z","size":197,"stargazers_count":25,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-19T00:14:54.680Z","etag":null,"topics":["aws","cloudwatch-events","cron","eventbridge","golang","parser"],"latest_commit_sha":null,"homepage":"https://cronplan.in","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/winebarrel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"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}},"created_at":"2022-10-16T12:44:36.000Z","updated_at":"2024-09-05T08:21:20.000Z","dependencies_parsed_at":"2024-06-21T07:27:25.480Z","dependency_job_id":"5c38376c-8e06-4e2f-8f67-fe8dcb889282","html_url":"https://github.com/winebarrel/cronplan","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winebarrel%2Fcronplan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winebarrel%2Fcronplan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winebarrel%2Fcronplan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winebarrel%2Fcronplan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/winebarrel","download_url":"https://codeload.github.com/winebarrel/cronplan/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235059576,"owners_count":18929289,"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":["aws","cloudwatch-events","cron","eventbridge","golang","parser"],"created_at":"2024-10-02T01:40:44.948Z","updated_at":"2025-01-22T04:09:46.212Z","avatar_url":"https://github.com/winebarrel.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cronplan\n\n[![CI](https://github.com/winebarrel/cronplan/actions/workflows/ci.yml/badge.svg)](https://github.com/winebarrel/cronplan/actions/workflows/ci.yml)\n[![Go Reference](https://pkg.go.dev/badge/github.com/winebarrel/cronplan.svg)](https://pkg.go.dev/github.com/winebarrel/cronplan)\n[![Go Report Card](https://goreportcard.com/badge/github.com/winebarrel/cronplan)](https://goreportcard.com/report/github.com/winebarrel/cronplan)\n\n## Overview\n\nCron expression parser for Amazon EventBridge.\n\n### Try with curl\n\n```sh\n$ curl cronplan.in -d '5 0 10 * ? *'\nTue, 10 Oct 2023 00:05:00\nFri, 10 Nov 2023 00:05:00\nSun, 10 Dec 2023 00:05:00\nWed, 10 Jan 2024 00:05:00\nSat, 10 Feb 2024 00:05:00\nSun, 10 Mar 2024 00:05:00\nWed, 10 Apr 2024 00:05:00\nFri, 10 May 2024 00:05:00\nMon, 10 Jun 2024 00:05:00\nWed, 10 Jul 2024 00:05:00\n```\n\n## Installation\n\n```sh\ngo get github.com/winebarrel/cronplan\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/winebarrel/cronplan\"\n)\n\nfunc main() {\n\tcron, err := cronplan.Parse(\"0 10 * * ? *\")\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(cron.Minute.Exps[0].Number) //=\u003e 0\n\tfmt.Println(cron.Hour.Exps[0].Number)   //=\u003e 10\n\tfmt.Println(cron.String())              //=\u003e \"0 10 * * ? *\"\n\n\tfmt.Println(cron.Match(time.Date(2022, 11, 3, 9, 0, 0, 0, time.UTC)))\n\t//=\u003e false\n\tfmt.Println(cron.Match(time.Date(2022, 11, 3, 10, 0, 0, 0, time.UTC)))\n\t//=\u003e true\n\n\tfmt.Println(cron.Next(time.Date(2022, 11, 3, 10, 0, 0, 0, time.UTC)))\n\t//=\u003e 2022-11-03 10:00:00 +0000 UTC\n\tfmt.Println(cron.Next(time.Date(2022, 11, 3, 11, 0, 0, 0, time.UTC)))\n\t//=\u003e 2022-11-04 10:00:00 +0000 UTC\n\tfmt.Println(cron.NextN(time.Date(2022, 11, 3, 10, 0, 0, 0, time.UTC), 3))\n\t//=\u003e [2022-11-03 10:00:00 +0000 UTC 2022-11-04 10:00:00 +0000 UTC 2022-11-05 10:00:00 +0000 UTC]\n\n\tfmt.Println(cron.Between(\n\t\ttime.Date(2022, 11, 3, 10, 0, 0, 0, time.UTC),\n\t\ttime.Date(2022, 11, 4, 10, 0, 0, 0, time.UTC),\n\t))\n\t//=\u003e [2022-11-03 10:00:00 +0000 UTC 2022-11-04 10:00:00 +0000 UTC]\n}\n```\n\n## Behavior of \"L\" in day-of-week\n\nIf you specify \"L\" for day-of-week, the last day of the week of each month is usually matched.\n\n```\n# cron(0 0 ? * 6L *)\nFri, 27 Oct 2023 00:00:00\nFri, 24 Nov 2023 00:00:00\nFri, 29 Dec 2023 00:00:00\nFri, 26 Jan 2024 00:00:00\nFri, 23 Feb 2024 00:00:00\n```\n\nHowever, if you do not specify the day of the week before \"L\", the behavior will be the same as when you specify \"SAT\".\n\n```\n# cron(0 0 ? * L *) = cron(0 0 ? * SAT *)\nSat, 07 Oct 2023 00:00:00\nSat, 14 Oct 2023 00:00:00\nSat, 21 Oct 2023 00:00:00\nSat, 28 Oct 2023 00:00:00\nSat, 04 Nov 2023 00:00:00\n```\n\n# cronplan CLI\n\nCLI to show next triggers.\n\n## Installation\n\n```\nbrew install winebarrel/cronplan/cronplan\n```\n\n## Usage\n\n```\nUsage: cronplan [OPTION] CRON_EXPR\n  -h int\n    \thour to add\n  -n int\n    \tnumber of next triggers (default 10)\n  -version\n    \tprint version and exit\n```\n\n```\n$ cronplan '*/10 10 ? * MON-FRI *'\nTue, 11 Oct 2022 10:00:00\nTue, 11 Oct 2022 10:10:00\nTue, 11 Oct 2022 10:20:00\nTue, 11 Oct 2022 10:30:00\nTue, 11 Oct 2022 10:40:00\nTue, 11 Oct 2022 10:50:00\nWed, 12 Oct 2022 10:00:00\nWed, 12 Oct 2022 10:10:00\nWed, 12 Oct 2022 10:20:00\nWed, 12 Oct 2022 10:30:00\n\n$ cronplan -h -9 '*/10 10 ? * MON-FRI *'\nTue, 11 Oct 2022 01:00:00\nTue, 11 Oct 2022 01:10:00\nTue, 11 Oct 2022 01:20:00\nTue, 11 Oct 2022 01:30:00\nTue, 11 Oct 2022 01:40:00\nTue, 11 Oct 2022 01:50:00\nWed, 12 Oct 2022 01:00:00\nWed, 12 Oct 2022 01:10:00\nWed, 12 Oct 2022 01:20:00\nWed, 12 Oct 2022 01:30:00\n```\n\n# cronmatch CLI\n\nCLI to check if datetime matches cron expression.\n\n## Installation\n\n```\nbrew install winebarrel/cronplan/cronmatch\n```\n\n## Usage\n\n```\nUsage: cronmatch [OPTION] CRON_EXPR DATE\n  -h int\n    \thour to add\n  -no-color\n    \tdisable color output\n  -version\n    \tprint version and exit\n```\n\n```\n$ cronmatch -h -9 '0 1 * * ? *' '2022/10/20 10:00'\n'0 1 * * ? *' matches '2022/10/20 10:00' (offset: -9h)\n\n$ cronmatch '0 10 * * ? *' 'Oct 10, 2022, 10:10'\n'0 10 * * ? *' does not match 'Oct 10, 2022, 10:10'\n```\n\ncf. https://pkg.go.dev/github.com/araddon/dateparse#readme-extended-example\n\n# cronviz CLI\n\nCLI to visualize cron schedule.\n\ninspired by [cronv](https://github.com/takumakanari/cronv), [aws-cronv](https://www.npmjs.com/package/aws-cronv).\n\n## Installation\n\n```\nbrew install winebarrel/cronplan/cronviz\n```\n\n## Usage\n\n```\nUsage: cronviz [OPTION] [FILE]\n  -f string\n    \tfrom date (default current date)\n  -h int\n    \thour to add\n  -p string\n    \tperiod (default \"1d\")\n  -version\n    \tprint version and exit\n```\n\n```\n$ cat cron.txt\nbatch1  0 * * * ? *\nbatch2  30 */2 * * ? *\nbatch3  15,45 */3 * * ? *\n\n$ cronviz cron.txt \u003e output.html\n$ open output.html\n```\n\ncf. https://raw.githack.com/winebarrel/cronplan/main/_example/timeline.html\n\n# crongrep CLI\n\nCLI to grep with cron expression.\n\n## Installation\n\n```\nbrew install winebarrel/cronplan/crongrep\n```\n\n## Usage\n\n```\nUsage: crongrep [OPTION] CRON_EXPR\n  -version\n    \tprint version and exit\n```\n\n```\n$ cronplan -n 5 '10 12 */5 * ? *'\nFri, 06 Oct 2023 12:10:00\nWed, 11 Oct 2023 12:10:00\nMon, 16 Oct 2023 12:10:00\nSat, 21 Oct 2023 12:10:00\nThu, 26 Oct 2023 12:10:00\n\n$ cronplan -n 5 '10 12 */5 * ? *' | crongrep '* * ? * WED-FRI *'\nFri, 06 Oct 2023 12:10:00\nWed, 11 Oct 2023 12:10:00\nThu, 26 Oct 2023 12:10:00\n```\n\n# cronskd CLI\n\nCLI to show a schedule of cron expressions.\n\n## Installation\n\n```\nbrew install winebarrel/cronplan/cronskd\n```\n\n## Usage\n\n```\nUsage: cronskd [OPTION] [FILE]\n  -e string\n    \tend date (default: end of day)\n  -s string\n    \tstart date (default: beginning of day)\n  -version\n    \tprint version and exit\n```\n\n```\n$ cat exprs.txt\n0 10 * * ? *\n15 12 * * ? *\n0 18 ? * MON-FRI *\n0 8 1 * ? *\n5 8-10 ? * MON-FRI *\n\n$ cronskd -s '2024-11-11' exprs.txt\nMon, 11 Nov 2024 08:05:00    5 8-10 ? * MON-FRI *\nMon, 11 Nov 2024 09:05:00    5 8-10 ? * MON-FRI *\nMon, 11 Nov 2024 10:00:00    0 10 * * ? *\nMon, 11 Nov 2024 10:05:00    5 8-10 ? * MON-FRI *\nMon, 11 Nov 2024 12:15:00    15 12 * * ? *\nMon, 11 Nov 2024 18:00:00    0 18 ? * MON-FRI *\n\n$ cronskd -s '2024/11/12 10:00' -e 'Nov 13, 2024, 12:00' exprs.txt\nTue, 12 Nov 2024 10:00:00\t0 10 * * ? *\nTue, 12 Nov 2024 10:05:00\t5 8-10 ? * MON-FRI *\nTue, 12 Nov 2024 12:15:00\t15 12 * * ? *\nTue, 12 Nov 2024 18:00:00\t0 18 ? * MON-FRI *\nWed, 13 Nov 2024 08:05:00\t5 8-10 ? * MON-FRI *\nWed, 13 Nov 2024 09:05:00\t5 8-10 ? * MON-FRI *\nWed, 13 Nov 2024 10:00:00\t0 10 * * ? *\nWed, 13 Nov 2024 10:05:00\t5 8-10 ? * MON-FRI *\n```\n\ncf. https://pkg.go.dev/github.com/araddon/dateparse#readme-extended-example\n\n## Related Links\n\n* https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-scheduled-rule-pattern.html#eb-cron-expressions\n* https://github.com/winebarrel/terraform-provider-cronplan\n* [Cron Trigger Tutorial](http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinebarrel%2Fcronplan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwinebarrel%2Fcronplan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinebarrel%2Fcronplan/lists"}