A lightweight cron expression parser for MicroPython and Python.
Project description
mp-cron-parser
A lightweight cron expression parser for MicroPython and Python.
Perfect for task scheduling and timers in embedded, IoT, and microcontroller projects.
Installation
mpremote mip install github:aviram26/mp-cron-parser
Features
- Standard cron syntax: 5 fields: minute, hour, day, month, day-of-week (
min hour dom mon dow) - Human-friendly aliases: Supports
@yearly,@monthly,@weekly,@daily,@hourly - Supports ranges, steps, and lists: (e.g.
0-30/5,MON-FRI,JAN,JUN,DEC) - Strict minimalism: No dependencies except for Python’s standard
timemodule - Rejects non-standard extensions: (
L,W,#) for smaller and safer code - Returns the next run time after any given timestamp
- Requires only the
timestandard module
Supported Syntax
| Field | Allowed values | Aliases | Example |
|---|---|---|---|
| minute | 0–59, *, ,, -, / |
- | 0,15,30,45 |
| hour | 0–23, *, ,, -, / |
- | 8-18/2 |
| day | 1–31, *, ,, -, / |
- | 1,15,29 |
| month | 1–12, *, ,, -, / |
JAN–DEC | JAN,JUN,DEC |
| weekday | 0–7, *, ,, -, / |
SUN–SAT (0 or 7) | MON-FRI |
Special Aliases:
| Alias | Equivalent |
|---|---|
@yearly |
0 0 1 1 * |
@monthly |
0 0 1 * * |
@weekly |
0 0 * * 0 |
@daily |
0 0 * * * |
@hourly |
0 * * * * |
Note: Non-standard cron features such as L, W, and # are not supported and will raise a ValueError.
Error Handling
Any cron expression that uses unsupported features or is malformed will raise a clear ValueError.
Usage
Here is a simple example demonstrating how to use mp-cron-parser to schedule and compute the time of the next scheduled job:
from cron_parser import Cron
cron = Cron('0 17 */2 * *')
n = cron.next_run()
License
Licensed under the MIT License.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mp_cron_parser-0.1.5.tar.gz.
File metadata
- Download URL: mp_cron_parser-0.1.5.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ff8d40a48efb021dd32858f7e10b66f354ac3ecfc2f60ac9eb6631eaa385720
|
|
| MD5 |
f13ce67e7fa1c39250793f8839f84c2c
|
|
| BLAKE2b-256 |
969a94dd9cdd529c1fb19f704fc9d7f2d6c6018feb8041aaf447a64ebaea7351
|
Provenance
The following attestation bundles were made for mp_cron_parser-0.1.5.tar.gz:
Publisher:
publish-to-pypi.yml on aviram26/mp-cron-parser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mp_cron_parser-0.1.5.tar.gz -
Subject digest:
9ff8d40a48efb021dd32858f7e10b66f354ac3ecfc2f60ac9eb6631eaa385720 - Sigstore transparency entry: 237526624
- Sigstore integration time:
-
Permalink:
aviram26/mp-cron-parser@c4cf0e42393d60594f5e27eac5b886eb33439f18 -
Branch / Tag:
refs/tags/0.1.5 - Owner: https://github.com/aviram26
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@c4cf0e42393d60594f5e27eac5b886eb33439f18 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mp_cron_parser-0.1.5-py3-none-any.whl.
File metadata
- Download URL: mp_cron_parser-0.1.5-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
268b468ed584a198ec90300a7be5be25e64d5d5731d4630bff63f230d4b1b36b
|
|
| MD5 |
7b62f529c72dd204b8b55cbf7b3d1ed8
|
|
| BLAKE2b-256 |
4f3da68584292aad754c5c0f85125fd4ac40bf74c2141119211f9659dd93ea65
|
Provenance
The following attestation bundles were made for mp_cron_parser-0.1.5-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on aviram26/mp-cron-parser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mp_cron_parser-0.1.5-py3-none-any.whl -
Subject digest:
268b468ed584a198ec90300a7be5be25e64d5d5731d4630bff63f230d4b1b36b - Sigstore transparency entry: 237526627
- Sigstore integration time:
-
Permalink:
aviram26/mp-cron-parser@c4cf0e42393d60594f5e27eac5b886eb33439f18 -
Branch / Tag:
refs/tags/0.1.5 - Owner: https://github.com/aviram26
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@c4cf0e42393d60594f5e27eac5b886eb33439f18 -
Trigger Event:
push
-
Statement type: