Chronometry Spelled Out
Details | |
Features |
Date-expression domain specific language (DSL) parsing. A neat way to express things like "First Saturday of any year", or "3rd thursdays each month" and such.
CronSpell is currently in Beta. While it is considered well tested and stable for most use cases, there may still be some edge cases and bugs that need to be addressed. The maintainer encourages users to try it out and provide feedback to help improving the library.
Your contributions and bug reports are highly appreciated.
Cronspell is heavily inspired by Grafana's relative Date picker user interface. It was designed for the cases when configuration is needed to reflect irregular date-distances.
Use it within your Python project or via command line interface.
Installation: pip install cronspell
The same interface, exposed to the command line. Formatted via isodate
by default -- which is
open for coniguration using the --format
option.
Installation with cli-specific dependencies: pip install cronspell[cli]
// a comment
/*
multi-line
comment ...
*/
/m -1d /sat
The same, more verbose:
/month -1day /sat
By enclosing a set in curly braces ({}
), a comma seperated list of datetime designators is evaluated.
// here comes a set of datetime designators
{
// first saturday of the month:
/m -1d /sat + 7d,
// sunday of every second calendar week:
@cw 2 + 6d
}
Timezone Designation
// `now` is the default anchor for subsequent designators.
// passing a timezone name to get the results with the same timezone:
now[Europe/Berlin] {
// first saturday of the month:
/m -1d /sat + 7d,
// sunday of every second calendar week:
@cw 2 + 6d
}
This package comes with a pre-commit hook that allows for automated
preflight checks on yaml
files serving as sources for cronspell expressions.
Put this in your .pre-commit-config.yaml
and adjust according to your needs:
repos:
- repo: https://github.com/iilei/cronspell
rev: c2b316f53c536e808353d2b30b97d1660c267d4b # v0.4.1
hooks:
- id: cronspell
files: .*\/cfg\.ya?ml$
args: ["--yamlpath", "/*/*date*" ]
- Domain-Specific-Language Parser: TextX
- This package was created with The Hatchlor project template.