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-1.0.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-1.0.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dateling-1.0.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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f699c7d62ab1b6ec9f6d0c64d0bf0c0a677ba8db8da1bce8ed0bf8aed7b205d9
MD5 91b7b0670324db61c6884d66e88d363a
BLAKE2b-256 1e3e7b7f816652681c2dea4743534bcf0f8801853a16cc4e3f031ec0722e1648

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dateling-1.0.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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d3685e441ba1732e6c0e6d29eda1aef0fd88bd11769f5f755edb07a786f4991
MD5 726db823c20bd993266ccdcd9aa00b2d
BLAKE2b-256 720e18331a50c728ab0cbd1fd66eeedb0ef11bd7d7ef1a28da78bbc58b0d7b42

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