{"id":13581775,"url":"https://github.com/lnquy/cron","last_synced_at":"2025-12-28T19:13:07.039Z","repository":{"id":56167560,"uuid":"254379149","full_name":"lnquy/cron","owner":"lnquy","description":"CLI tool (hcron) and Go library (cron) to convert CRON expression into human readable description.","archived":false,"fork":false,"pushed_at":"2020-11-23T07:13:06.000Z","size":2838,"stargazers_count":92,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-05T21:45:10.105Z","etag":null,"topics":["cli","cron","cron-expression","cron-libraries","go","golang","module","quartz"],"latest_commit_sha":null,"homepage":"","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/lnquy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-09T13:29:39.000Z","updated_at":"2024-10-10T18:41:45.000Z","dependencies_parsed_at":"2022-08-15T14:00:30.773Z","dependency_job_id":null,"html_url":"https://github.com/lnquy/cron","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnquy%2Fcron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnquy%2Fcron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnquy%2Fcron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnquy%2Fcron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lnquy","download_url":"https://codeload.github.com/lnquy/cron/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247470493,"owners_count":20944146,"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":["cli","cron","cron-expression","cron-libraries","go","golang","module","quartz"],"created_at":"2024-08-01T15:02:14.286Z","updated_at":"2025-12-28T19:13:06.953Z","avatar_url":"https://github.com/lnquy.png","language":"Go","readme":"# cron\n\u003cp align=\"left\"\u003e\n  \u003ca href=\"https://godoc.org/github.com/lnquy/cron\" title=\"GoDoc Reference\" rel=\"nofollow\"\u003e\u003cimg src=\"https://img.shields.io/badge/go-documentation-blue.svg?style=flat\" alt=\"GoDoc Reference\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/github.com/lnquy/cron/releases/tag/v1.0.0\" title=\"1.0.0 Release\" rel=\"nofollow\"\u003e\u003cimg src=\"https://img.shields.io/badge/version-1.0.0-blue.svg?style=flat\" alt=\"1.0.0 release\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://goreportcard.com/report/github.com/lnquy/cron\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/lnquy/cron\" alt=\"Code Status\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://travis-ci.org/lnquy/cron\"\u003e\u003cimg src=\"https://travis-ci.org/lnquy/cron.svg?branch=master\" alt=\"Build Status\" /\u003e\u003c/a\u003e\n  \u003ca href='https://coveralls.io/github/lnquy/cron?branch=master'\u003e\u003cimg src='https://coveralls.io/repos/github/lnquy/cron/badge.svg?branch=master' alt='Coverage Status' /\u003e\u003c/a\u003e\n  \u003cbr /\u003e\n\u003c/p\u003e\n\ncron is a Go library that parses a cron expression and outputs a human readable description of the cron schedule.  \nFor example, given the expression `*/5 * * * *` it will output `Every 5 minutes`.  \n\nTranslated to Go from [cron-expression-descriptor](https://github.com/bradymholt/cron-expression-descriptor) (C#) via [cRonstrue](https://github.com/bradymholt/cRonstrue) (Javascript).  \nOriginal Author \u0026 Credit: Brady Holt (http://www.geekytidbits.com).\n\n## Features\n- Zero dependencies\n- Supports all cron expression special characters including `* / , - ? L W #`\n- Supports 5, 6 (w/ seconds or year), or 7 (w/ seconds and year) part cron expressions\n- Supports [Quartz Job Scheduler](http://www.quartz-scheduler.org/) cron expressions\n- i18n support with 26 locales.\n\n## Installation\n`cron` module can be used with both Go module (\u003e= 1.11) and earlier Go versions.\n```\ngo get -u -v github.com/lnquy/cron\n```\n\n## Usage\n\n```go\n// Init with default EN locale\nexprDesc, _ := cron.NewDescriptor()\n\ndesc, _ := exprDesc.ToDescription(\"* * * * *\", cron.Locale_en)\n// \"Every minute\" \n\ndesc, _ := exprDesc.ToDescription(\"0 23 ? * MON-FRI\", cron.Locale_en)\n// \"At 11:00 PM, Monday through Friday\" \n\ndesc, _ := exprDesc.ToDescription(\"23 14 * * SUN#2\", cron.Locale_en)\n// \"At 02:23 PM, on the second Sunday of the month\"\n\n// Init with custom configs\nexprDesc, _ := cron.NewDescriptor(\n    cron.Use24HourTimeFormat(true),\n    cron.DayOfWeekStartsAtOne(true),\n    cron.Verbose(true),\n    cron.SetLogger(log.New(os.Stdout, \"cron: \", 0)),\n    cron.SetLocales(cron.Locale_en, cron.Locale_fr),\n)\n```\n\nFor more usage examples, including a demonstration of how cron can handle some very complex cron expressions, you can reference [the unit tests](https://github.com/lnquy/cron/blob/develop/locale_en_test.go) or [the example codes](https://github.com/lnquy/cron/tree/develop/examples).\n\n## i18n\n\nTo use the i18n support, you must configure the locales when create a new `ExpressionDescriptor` via `SetLocales()` option.\n```go\nexprDesc, _ := cron.NewDescriptor(\n    cron.SetLocales(cron.Locale_en, cron.Locale_es, cron.Locale_fr),\n)\n// or load all cron.LocaleAll\nexprDesc, _ := cron.NewDescriptor(cron.SetLocales(cron.LocaleAll))\n\ndesc, _ := exprDesc.ToDescription(\"* * * * *\", cron.Locale_fr)\n// Toutes les minutes\n```\n\nBy default, `ExpressionDescriptor` always load the `Locale_en`. If you pass an unregistered locale into `ToDescription()` function, the result will be returned in English.\n\n### Supported Locales\n\n| Locale Code | Language             | Contributors                                               |\n| ----------- | -------------------- | ---------------------------------------------------------- |\n|  cs         | Czech                | [hanbar](https://github.com/hanbar)                        |\n|  da         | Danish               | [Rasmus Melchior Jacobsen](https://github.com/rmja)        |\n|  de         | German               | [Michael Schuler](https://github.com/mschuler)             |\n|  en         | English              | [Brady Holt](https://github.com/bradymholt)                |\n|  es         | Spanish              | [Ivan Santos](https://github.com/ivansg)                   |\n|  fa         | Farsi                | [A. Bahrami](https://github.com/alirezakoo)                |\n|  fi         | Finnish              | [Mikael Rosenberg](https://github.com/MR77FI)              |\n|  fr         | French               | [Arnaud TAMAILLON](https://github.com/Greybird)            |\n|  he         | Hebrew               | [Ilan Firsov](https://github.com/IlanF)                    |\n|  it         | Italian              | [rinaldihno](https://github.com/rinaldihno)                |\n|  ja         | Japanese             | [Alin Sarivan](https://github.com/asarivan)                |\n|  ko         | Korean               | [Ion Mincu](https://github.com/ionmincu)                   |\n|  nb         | Norwegian            | [Siarhei Khalipski](https://github.com/KhalipskiSiarhei)   |\n|  nl         | Dutch                | [TotalMace](https://github.com/TotalMace)                  |\n|  pl         | Polish               | [foka](https://github.com/foka)                            |\n|  pt_BR      | Portuguese (Brazil)  | [Renato Lima](https://github.com/natenho)                  |\n|  ro         | Romanian             | [Illegitimis](https://github.com/illegitimis)              |\n|  ru         | Russian              | [LbISS](https://github.com/LbISS)                          |\n|  sk         | Slovakian            | [hanbar](https://github.com/hanbar)                        |\n|  sl         | Slovenian            | [Jani Bevk](https://github.com/jenzy)                      |\n|  sv         | Swedish              | [roobin](https://github.com/roobin)                        |\n|  sw         | Swahili              | [Leylow Lujuo](https://github.com/leyluj)                  |\n|  tr         | Turkish              | [Mustafa SADEDİL](https://github.com/sadedil)              |\n|  uk         | Ukrainian            | [Taras](https://github.com/tbudurovych)                    |\n|  zh_CN      | Chinese (Simplified) | [Star Peng](https://github.com/starpeng)                   |\n|  zh_TW      | Chinese (Traditional)| [Ricky Chiang](https://github.com/metavige)                |\n\n\n\n## hcron\n\n`hcron` is the CLI tool to convert the CRON expression to human readable string.  \nYou can pass the CRON expressions as the program argument, piped `hcron` with stdin or given the path to crontab file.\n\n### Install\n\nYou can find the pre-built binaries for Linux, MacOS, FreeBSD and Windows from the [Release](https://github.com/lnquy/cron/releases).  \n\nFor other OS or architecture, you can build the code using Go as below:\n\n```shell\n$ go get -u -v github.com/lnquy/cron/cmd/hcron\n\n# or\n\n$ git clone https://github.com/lnquy/cron\n$ cd cron/cmd/hcron\n$ go build\n```\n\n### Usage\n\n```shell\n$ hcron -h\nhcron converts the CRON expression to human readable description.\n\nUsage:\n  hcron [flags] [cron expression]\n\nFlags:\n  -24-hour\n        Output description in 24 hour time format\n  -dow-starts-at-one\n        Is day of the week starts at 1 (Monday-Sunday: 1-7)\n  -file string\n        Path to crontab file\n  -h    Print help then exit\n  -locale string\n        Output description in which locale (default \"en\")\n  -print-all\n        Also print all the lines which is not a valid cron\n  -v    Print app version then exit\n  -verbose\n        Output description in verbose format\n\nExamples:\n  $ hcron \"0 15 * * 1-5\"\n  $ hcron \"0 */10 9 * * 1-5 2020\"\n  $ hcron -locale fr \"0 */10 9 * * 1-5 2020\"\n  $ hcron -file /var/spool/cron/crontabs/mycronfile\n  $ another-app | hcron \n  $ another-app | hcron --dow-starts-at-one --24-hour -locale es\n```\n\n\n\n## Project status\n\n- [x] Port 1-1 code from cRonstrue Javascript\n- [X] Port and pass all test cases from cRonstrue\n- [X] i18n for 25 languages\n- [X] Test cases i18n\n- [x] Fix i18n issues of FA, HE, RO, RU, UK, ZH_CN and ZH_TW\n- [x] hcron CLI tool\n- [x] Performance improvement\n- [x] Release v1.0.0\n\n## License\n\nThis project is under the MIT License. See the [LICENSE](https://github.com/lnquy/cron/blob/master/LICENSE) file for the full license text.\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flnquy%2Fcron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flnquy%2Fcron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flnquy%2Fcron/lists"}