A small tool for processing crontab syntax
Project description
Cronparse
A simple tool for testing crontab like syntax.
Usage
>>> from cronparse import Cron
>>> c = Cron('*/5 * * * 0') # Matches only on Mondays, every 5th minute
>>> from datetime import datetime
>>> d = datetime(2020, 4, 13, 11, 5)
>>> c.matches(d)
True
>>> d = d.replace(minute=6)
>>> c.matches(d)
False
>>> d = d.replace(day=14, minute=5)
>>> c.matches(d)
False
>>> c.why(d) # Ask which fragment of the rule did not match
[True, True, True, True, False]
crontab rule syntax
Supported syntax:
- * - match any value
- 1 - match exact value
- */5 - match every 5th value
- 1,3,4 - match values from list
- 1-3 - match values in a range
- 1-3,7,*/2 - combinations!
- @yearly, @annually, @monthly, @weekly, @daily, @midnight, @hourly
Unsupported syntax:
- Day names
- Month names
- @reboot
Timezone Support
Optionally, you can pass a datetime.tzinfo
as the second argument. It
defaults to datetime.timezone.utc
.
Any datetime
passed for testing will first be moved to that timezone.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cronparse-0.1.0.tar.gz
(2.6 kB
view hashes)
Built Distribution
Close
Hashes for cronparse-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd7951c6150cec173fef455e221a5c2e819b89a49a77c6e9602ac54658a54acb |
|
MD5 | 18b9b38be344ee5229623e402b298c42 |
|
BLAKE2b-256 | e8c2019dca8ddd54e0dedf671de27da2f84fc8f711d373af3d08c992898d4a1a |