Skip to main content

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 time module
  • Rejects non-standard extensions: (L, W, #) for smaller and safer code
  • Returns the next run time after any given timestamp
  • Requires only the time standard 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mp_cron_parser-0.1.5.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mp_cron_parser-0.1.5-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

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

Hashes for mp_cron_parser-0.1.5.tar.gz
Algorithm Hash digest
SHA256 9ff8d40a48efb021dd32858f7e10b66f354ac3ecfc2f60ac9eb6631eaa385720
MD5 f13ce67e7fa1c39250793f8839f84c2c
BLAKE2b-256 969a94dd9cdd529c1fb19f704fc9d7f2d6c6018feb8041aaf447a64ebaea7351

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for mp_cron_parser-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 268b468ed584a198ec90300a7be5be25e64d5d5731d4630bff63f230d4b1b36b
MD5 7b62f529c72dd204b8b55cbf7b3d1ed8
BLAKE2b-256 4f3da68584292aad754c5c0f85125fd4ac40bf74c2141119211f9659dd93ea65

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page