Skip to main content

Date-expression domain specific language parsing. A neat way to express things like "First Saturday of any year", or "3rd thursdays each month" and such

Project description

Cronspell Python Package / CLI Tool

Chronometry Spelled Out

Github Pages

Details Tests License - MIT
Features linting - Ruff types - mypy test - pytest Pre-Commit docs - mkdocs

Date-expression domain specific language parsing. A neat way to express things like "First Saturday of any year", or "3rd thursdays each month" and such.

Features

Python

Cronspell is heavily inspired by Grafana's relative Date picker user interface. It shines when configuration is needed to reflect irregular date-distances such as in the example below.

cronspell lets you express relative dates such as "last saturday of last month" and converts it to a date object for use in your python project.

from cronspell import cronspell

# Cronspell's purpose is mostly to parse configuration files written in yaml
# and therein express relative date times in a human friendly manner.

# here is but a simple demo:
last_saturday = cronspell("now/sat")
...

Cli

The same interface, exposed to the command line. Formatted via isodate by default -- which is open for configuration using the --format option.

This is how you get the last saturday of the current month, for example:

cronspell parse "now /month + 34 days /m -1d /sat"

Example

To get the last saturday of last month:

"now /m -1d /sat"

The same, more verbose:

"now /month -1day /sat"

Pre-Commit Hook: Validation

Cronspell comes with a pre-commit hook that validates configured date-expressions based on yamlpath.

Given you have simple config files in yaml format containing arrays of objects having a key cronspell, here is an example pre-commit hook config:

  - repo: https://github.com/iilei/cronspell
    rev: <release tag>
    hooks:
      - id: cronspell

Credits

  • Domain-Specific-Language Parser: TextX
  • This package was created with The Hatchlor project template.

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

cronspell-0.0.0rc16.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

cronspell-0.0.0rc16-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file cronspell-0.0.0rc16.tar.gz.

File metadata

  • Download URL: cronspell-0.0.0rc16.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for cronspell-0.0.0rc16.tar.gz
Algorithm Hash digest
SHA256 6902260ed668afe188f6f868f09fa8421e550a866cfa564a35dd3fc98d619f42
MD5 8edf8d5668252e95f563d9522e1578ae
BLAKE2b-256 b2881fe9c30efbfae39e17087b72d2d00ed546e500403a9e388c3fcc2bb48956

See more details on using hashes here.

Provenance

The following attestation bundles were made for cronspell-0.0.0rc16.tar.gz:

Publisher: build.yml on iilei/cronspell

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

File details

Details for the file cronspell-0.0.0rc16-py3-none-any.whl.

File metadata

  • Download URL: cronspell-0.0.0rc16-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for cronspell-0.0.0rc16-py3-none-any.whl
Algorithm Hash digest
SHA256 2a63bf00feef8ab69b30b58c2b41e39a731980372bc202f21133bc9c65f05cae
MD5 7c578a9fbdfa7d438ad1273db580c9b6
BLAKE2b-256 9e49ca1cfa893389102196de6f28203a20f5ba8cbade8bcb679023d0ed78ca60

See more details on using hashes here.

Provenance

The following attestation bundles were made for cronspell-0.0.0rc16-py3-none-any.whl:

Publisher: build.yml on iilei/cronspell

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