pycron is a simple Python library for parsing cron-like expressions and determining if a given datetime matches the specified conditions. It supports standard cron formats, day names, and step values. The current version is 3.2.0, and the library is actively maintained with several releases per year.
pip install pycronVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use `is_now` to check if a cron expression matches a given datetime (or the current time), and `has_been` for checking if a condition was met within a time range.
Upgrade Python to a supported version (>=3.9, <4.0) or pin `pycron` to an older version like `pycron<3.0.0`.
Thoroughly test existing cron expressions when upgrading to `pycron >= 3.1.0` to ensure continued expected behavior, especially for expressions involving specific days of the month or week combinations.
Ensure that the datetime objects passed to `is_now` or `has_been` are consistently timezone-aware (preferably UTC) or consistently naive, matching the intended timezone context of your cron expressions.
Verify your Python environment meets the `>=3.9, <4.0` requirement before installing `pycron`.
Ensure that the `since` datetime object is strictly earlier than the `dt` (or current system) datetime object when calling `pycron.has_been`. For example, `since = dt - timedelta(hours=1)`.
Review the cron expression string for any non-numeric characters in fields that expect integer values, or for malformed ranges and step values. Ensure all parts conform to standard cron expression syntax.
Install the library using pip: `pip install pycron`. If already installed, ensure your Python environment path is correctly configured.
If you imported with `import pycron`, call the function as `pycron.is_now('expression')`. Alternatively, you can use `from pycron import is_now` to call it directly as `is_now('expression')`.No dependency data recorded yet.