{"id":13507745,"url":"https://github.com/maennchen/crontab","last_synced_at":"2025-04-05T06:06:13.820Z","repository":{"id":14786774,"uuid":"77094287","full_name":"maennchen/crontab","owner":"maennchen","description":":alarm_clock: Parse Cron Expressions, Compose Cron Expression Strings and Caluclate Execution Dates.","archived":false,"fork":false,"pushed_at":"2024-10-23T14:28:00.000Z","size":374,"stargazers_count":94,"open_issues_count":6,"forks_count":33,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-29T05:05:30.608Z","etag":null,"topics":["cron","crontab","elixir","schedule"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/crontab","language":"Elixir","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/maennchen.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-21T23:43:07.000Z","updated_at":"2024-12-25T10:08:50.000Z","dependencies_parsed_at":"2023-11-29T11:25:42.176Z","dependency_job_id":"4696b3df-cedd-4f81-b9e8-24e2182a2737","html_url":"https://github.com/maennchen/crontab","commit_stats":null,"previous_names":["jshmrtn/crontab"],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maennchen%2Fcrontab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maennchen%2Fcrontab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maennchen%2Fcrontab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maennchen%2Fcrontab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maennchen","download_url":"https://codeload.github.com/maennchen/crontab/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294537,"owners_count":20915340,"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","crontab","elixir","schedule"],"created_at":"2024-08-01T02:00:38.516Z","updated_at":"2025-04-05T06:06:13.803Z","avatar_url":"https://github.com/maennchen.png","language":"Elixir","readme":"\u003cpicture style=\"margin-right: 15px; float: right;\"\u003e\n  \u003csource\n    media=\"(prefers-color-scheme: dark)\"\n    srcset=\"assets/logo-dark.svg\"\n    width=\"180px\"\n    align=\"right\"\n  /\u003e\n  \u003csource\n    media=\"(prefers-color-scheme: light)\"\n    srcset=\"assets/logo-light.svg\"\n    width=\"180px\"\n    align=\"right\"\n  /\u003e\n  \u003cimg\n    src=\"assets/logo-light.svg\"\n    alt=\"Logo featuring a clock\"\n    width=\"180px\"\n    align=\"right\"\n  /\u003e\n\u003c/picture\u003e\n\n# Crontab\n\n[![CI](https://github.com/maennchen/crontab/workflows/.github/workflows/elixir.yml/badge.svg)](https://github.com/maennchen/crontab/actions?query=workflow%3A.github%2Fworkflows%2Felixir.yml)\n[![Coverage Status](https://coveralls.io/repos/github/maennchen/crontab/badge.svg?branch=main)](https://coveralls.io/github/maennchen/crontab?branch=main)\n[![Module Version](https://img.shields.io/hexpm/v/crontab.svg)](https://hex.pm/packages/crontab)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/crontab/)\n[![Total Download](https://img.shields.io/hexpm/dt/crontab.svg)](https://hex.pm/packages/crontab)\n[![License](https://img.shields.io/hexpm/l/crontab.svg)](https://github.com/maennchen/crontab/blob/main/LICENSE)\n[![Last Updated](https://img.shields.io/github/last-commit/maennchen/crontab.svg)](https://github.com/maennchen/crontab/commits/main)\n\nElixir library for parsing, writing, and calculating Cron format strings.\n\n\u003cbr clear=\"left\"/\u003e\n\n## Installation\n\nAdd `:crontab` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:crontab, \"~\u003e 1.1\"}\n  ]\nend\n```\n\n## Usage\n\n### Import Cron expression sigil\n\nEverywhere you want to use the Cron expression sigil (`e[cron expression]`).\n\n```elixir\nimport Crontab.CronExpression\n```\n\n### Extended Cron expressions\n\nAn extended Cron expression has more precision than a normal Cron expression.\nIt also specifies the second.\n\nIf you want to use extended Cron expressions with the sigil, just append an `e`.\n\n### Checking if a Cron Expression Matches a date\n\n```elixir\niex\u003e import Crontab.CronExpression\niex\u003e Crontab.DateChecker.matches_date?(~e[*/2], ~N[2017-01-01 01:01:00])\nfalse\niex\u003e Crontab.DateChecker.matches_date?(~e[*], ~N[2017-01-01 01:01:00])\ntrue\n```\n\n### Find Next / Previous Execution Date candidates\n\nAll the date parameters default to now.\n\nFor previous, just replace `next` in the code below.\n\n```elixir\niex\u003e import Crontab.CronExpression\niex\u003e Crontab.Scheduler.get_next_run_date(~e[*/2], ~N[2017-01-01 01:01:00])\n{:ok, ~N[2017-01-01 01:02:00]}\niex\u003e Crontab.Scheduler.get_next_run_date!(~e[*/2], ~N[2017-01-01 01:01:00])\n~N[2017-01-01 01:02:00]\n```\n\n```elixir\niex\u003e Enum.take(Crontab.Scheduler.get_next_run_dates(~e[*/2], ~N[2017-01-01 01:01:00]), 3)\n[~N[2017-01-01 01:02:00], ~N[2017-01-01 01:04:00], ~N[2017-01-01 01:06:00]]\n```\n\n### Parse Cron Expressions\n\nIf you statically define cron expressions, use the `~e[cron expression]` sigil.\n\nFor dynamic cron expressions, there is a Parser module.\n\nThe parser module takes an optional `extended` flag. This is to mark if the\nexpression contains seconds. This defaults to `false`.\n\n```elixir\niex\u003e Crontab.CronExpression.Parser.parse \"* * * * *\"\n{:ok,\n  %Crontab.CronExpression{day: [:*], hour: [:*], minute: [:*],\n  month: [:*], weekday: [:*], year: [:*]}}\niex\u003e Crontab.CronExpression.Parser.parse! \"* * * * *\"\n%Crontab.CronExpression{day: [:*], hour: [:*], minute: [:*],\n month: [:*], weekday: [:*], year: [:*]}\n```\n\n### Compose Cron expressions\n\n```elixir\niex\u003e Crontab.CronExpression.Composer.compose %Crontab.CronExpression{}\n\"* * * * * *\"\niex\u003e Crontab.CronExpression.Composer.compose %Crontab.CronExpression{minute: [9, {:-, 4, 6}, {:/, :*, 9}]}\n\"9,4-6,*/9 * * * * *\"\n```\n\n## Copyright and License\n\nCopyright (c) 2016, SK \u0026 T AG, JOSHMARTIN GmbH, Jonatan Männchen\n\nThis library is MIT licensed. See the [LICENSE](https://github.com/maennchen/crontab/blob/main/LICENSE) for details.\n","funding_links":[],"categories":["Date and Time"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaennchen%2Fcrontab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaennchen%2Fcrontab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaennchen%2Fcrontab/lists"}