{"id":23727774,"url":"https://github.com/kipe/pycron","last_synced_at":"2025-04-09T11:05:40.176Z","repository":{"id":33904620,"uuid":"37620216","full_name":"kipe/pycron","owner":"kipe","description":"Simple cron-like parser for Python, which determines if current datetime matches conditions","archived":false,"fork":false,"pushed_at":"2025-01-14T06:52:14.000Z","size":134,"stargazers_count":164,"open_issues_count":2,"forks_count":26,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-02T09:57:15.944Z","etag":null,"topics":["cron","python"],"latest_commit_sha":null,"homepage":"","language":"Python","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/kipe.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":"2015-06-17T20:51:58.000Z","updated_at":"2025-03-29T12:58:36.000Z","dependencies_parsed_at":"2025-01-07T02:42:41.576Z","dependency_job_id":"804d6f25-c698-43aa-99e3-cffa16a5946c","html_url":"https://github.com/kipe/pycron","commit_stats":{"total_commits":64,"total_committers":5,"mean_commits":12.8,"dds":0.109375,"last_synced_commit":"4f0ece7370bb43b5de7f1dc493bf74e7b6f9a302"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kipe%2Fpycron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kipe%2Fpycron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kipe%2Fpycron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kipe%2Fpycron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kipe","download_url":"https://codeload.github.com/kipe/pycron/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248027407,"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","python"],"created_at":"2024-12-31T01:30:06.252Z","updated_at":"2025-04-09T11:05:40.154Z","avatar_url":"https://github.com/kipe.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pycron\n\n![Test Status](https://github.com/kipe/pycron/actions/workflows/python-test.yml/badge.svg?branch=main)\n\nSimple cron-like parser for Python, which determines if current datetime matches conditions.\n\n## Installation\n\n`pip install pycron`\n\n## Usage\n\n```python\nimport pycron\npycron.is_now('*/5 * * * *')  # True every 5 minutes\npycron.is_now('0 * * * *')    # True every hour, on minute 0\n```\n\n## Help\n\nThe formats currently supported are\n\n- `*/5` (for \"every X\" function),\n- `4-10` (for time ranges),\n- `6,8,23` (for a list of values),\n- `*` (for wildcard),\n- and of course a single number.\n\nThe module includes `is_now(s, dt=None)`, where `s` is the cron-style string\nand `dt` is the datetime to use (defaults to current datetime, if not set).\nThe function returns `True`, if `dt` matches the format.\n\nIt also includes `has_been(s, since, dt=None)`, where `s` is the cron-style string,\n`since` is a datetime in the past and `dt` is the datetime to use (defaults to current datetime, if not set).\nThe function returns `True`, if `dt` would have matched the format at some point during the period.\nThis behaves much like like [anacron](https://en.wikipedia.org/wiki/Anacron) and is useful for applications which do not run continuously.\n\nAll functions are compatible with both timezone aware and naive datetimes.\n\nThere are couple of helpers available, mainly for use with Django.\nThey give out list of tuples, as required by Django field choices.\n\nThe available helpers are\n\n- `pycron.MINUTE_CHOICES`,\n- `pycron.HOUR_CHOICES`,\n- `pycron.DOM_CHOICES`, for day of month\n- `pycron.MONTH_CHOICES`, for month names\n- `pycron.DOW_CHOICES`, for day names\n\n## Support for alternative datetime -libraries\n\nCurrently supported \"alternative\" datetime libraries are:\n\n- [Arrow](http://arrow.readthedocs.io/en/latest/)\n- [Delorean](http://delorean.readthedocs.io/en/latest/)\n- [Pendulum](https://pendulum.eustace.io/)\n- [udatetime](https://github.com/freach/udatetime)\n\n#### Notes\n\nThis was done, as I personally needed something like this to implement proper timers for my Django-project and\nevery available library felt too complicated for my use-case. Also, this was a good coding exercise...\n\nAs the Django -helper choices are quite limited, I've expanded them in my own project by adding values like\n`('*/5', 'every 5 minutes')`, `('1-5', 'on weekdays')`, and `('0,6', 'on weekends')`.\nI haven't included them in the code, as every use-case is different, this was just to give an idea on how to use this ;)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkipe%2Fpycron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkipe%2Fpycron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkipe%2Fpycron/lists"}