Skip to main content

dateling provides a normalized formal language and grammar for handling relative time expressions. It includes a DSL (domain-specific language) to represent time anchors, offsets, and modifiers, along with a robust parser and resolver to evaluate these expressions into concrete dates. The name 'dateling' comes from combining 'date' and 'handling', reflecting its purpose of handling complex date computations

Project description

dateling

dateling: A DSL parser and resolver for normalized date expressions

dateling provides a formalized expression language and grammar for handling relative and absolute date computations.
It defines a structured Date DSL (Domain-Specific Language) and provides a parser that resolves these expressions into actual dates.

The name dateling combines date and handling, representing its core purpose: structured date handling.


✅ Date Expression DSL

Format:

Anchors

  • today (current date)
  • YYYYMMDD (e.g., 20250101)
  • YYYY-MM-DD (e.g., 2025-01-01)

Offsets

  • +Nd, -Nd → days
  • +Nm, -Nm → months
  • +Ny, -Ny → years

Modifiers

  • year_start → start of year
  • year_end → end of year
  • year=infer_year → use anchor year; if resulting date is in future, fallback to previous year
  • year=YYYY → explicit year override
  • month=MM → month override
  • day=DD → day override

✅ Examples

DSL Expression Meaning
{today} today's date
{today - Nd} N days ago
{today - Ny} N years ago
`{today year_start}`
`{today year=infer_year, month=MM, day=DD}`
`{today -1y year_end}`

✅ Test Examples (executed on 2025-06-11)

DSL Resolved Date
{today} 2025-06-11
{today -1d} 2025-06-10
`{today -365d year=infer_year}`
{today -3y} 2022-06-11
`{today year_start}`
`{today year_end}`
`{today -1y year_start}`
`{today -1y year_end}`
`{today year=infer_year, month=06, day=10}`
`{today -1y year=infer_year, month=03, day=10}`
`{today year=2024, month=06, day=10}`
{year=2022, month=05, day=15} 2022-05-15
2025-01-01 2025-01-01
20250101 2025-01-01
`{1000-01-01 +30y year_end}`
{today -36m} 2022-06-11
`{today year=infer_year, month=06, day=10}`

✅ Install

pip install dateling

✅ Usage

from dateling import DatelingResolver

resolver = DatelingResolver()
date = resolver.resolve("{today -1y | year_start}")
print(date)

✅ License

MIT License


✅ Purpose

  • Fully normalized date expression language (DSL)
  • Precise parsing and evaluation of relative and absolute date computations
  • Designed for any system that needs structured time computations:
    • search systems
    • reporting tools
    • schedulers
    • time-based data processing

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

dateling-0.1.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

dateling-0.1.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file dateling-0.1.0.tar.gz.

File metadata

  • Download URL: dateling-0.1.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for dateling-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6ef7da41695dfb6b3931c9082f8db54010a3ec1f6ad32e730468a49f291ef5c3
MD5 a082921a2a9896d0cf571f7b3d42a3da
BLAKE2b-256 6ebc4db8e0b8a54c4c9c2c14024cf56702468d47208d3edf182929db6580acc3

See more details on using hashes here.

File details

Details for the file dateling-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dateling-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for dateling-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 99b0e3ec20de304ffdf3c852d749f2e8b3ba7990021ead3a8e9a746bf550a25f
MD5 89df5f0c83158f2949095a5854d95a17
BLAKE2b-256 a97b0f05df643260875039cf26ff8d2bf8609efdc4b3392ff6329afdfebcd5de

See more details on using hashes here.

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