Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

ovos-date-parser

This library turns date, time and duration phrases into datetime and timedelta values, and turns those values back into words. It reads 61 languages through chronologia and writes 39 languages with its own nice_* formatters.

The library is a plain Python package. It needs no voice assistant at runtime. OpenVoiceOS uses it, and so can an NER pipeline, a TTS front end, an ASR post-processor or a scheduler.

Install

uv pip install --prerelease=allow ovos-date-parser

Getting started

Reading a phrase gives a datetime and the words left over. Writing a value gives words that a speech engine can say.

from datetime import datetime
from ovos_date_parser import extract_datetime, extract_duration, nice_time, nice_duration

# text to datetime, plus the leftover words
when, leftover = extract_datetime("lets meet next friday at 8am", "en",
                                  anchorDate=datetime(2024, 1, 5))
print(when)      # 2024-01-12 08:00:00
print(leftover)  # lets meet

# text to timedelta
delta, leftover = extract_duration("set a timer for 5 minutes", "en")
print(delta)     # 0:05:00

# datetime to speakable words
print(nice_time(datetime(2024, 1, 5, 15, 30), "en"))   # half past three
print(nice_duration(3690, "en"))                       # one hour one minute thirty seconds

anchorDate is the "now" that relative phrases resolve against. Pass a fixed value for repeatable results.

Who does what

Reading is the job of chronologia. extract_datetime normalizes the language tag and calls chronologia for every locale it reads. extract_duration calls chronologia for the same locales. docs/languages.md lists each one. This package adds the datetime shape of the answer, the leftover text, named holidays, the resolution and replace_token options of extract_duration, and the span scans extract_datetime_spans and extract_duration_spans.

Writing is the job of this package. The nice_* functions and the spoken_* functions say a time, a date, a year or a duration in the words of a language.

A language that chronologia does not read, such as Japanese or Chinese, goes to dateparser. That fallback reads absolute dates well and conversational phrases poorly.

Languages

extract_datetime reads the 61 locales in CHRONOLOGIA_LOCALES. The nice_* formatters write 39 languages, and chronologia reads every one of them. docs/languages.md lists both sets. A tag in any case, with _ or -, reaches the same reader: "EN-US", "pt_br" and "deu" all work for reading.

Documentation

docs/index.md lists every page. The main ones:

Runnable scripts are in examples/. Run one with python examples/ner_temporal.py.

License

Apache 2.0.

Metadata

Release files for ovos-date-parser 0.41.1a5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ovos-date-parser 0.41.1a5
File Size Uploaded Provenance Actions
ovos_date_parser-0.41.1a5.tar.gz 389.6 kB Without provenance Details for ovos_date_parser-0.41.1a5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ovos-date-parser 0.41.1a5
File Interpreter ABI Platform Actions
ovos_date_parser-0.41.1a5-py3-none-any.whl Python 3 none any Details for ovos_date_parser-0.41.1a5-py3-none-any.whl

Total release size: 652.6 kB

Release files / ovos_date_parser-0.41.1a5.tar.gz

Download URL ovos_date_parser-0.41.1a5.tar.gz
Size 389.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c436cfe00e1f343b8a50b15bea057591ec575cd4ccf0d0c062b103ca7dd64ac2
BLAKE2b-256 checksum
How to use checksums
cb895b55360c890995ac3f73772458b7de29f06cdd22724d7186c261a6c05b85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ovos_date_parser-0.41.1a5-py3-none-any.whl

Download URL ovos_date_parser-0.41.1a5-py3-none-any.whl
Size 263.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22d4dd1aed3f6e60f0fe6ec5189cb9eb0b1d1d4155a388c53f97cc1632e90f26
BLAKE2b-256 checksum
How to use checksums
d286f1e525cbe0d78e84a9611e981eebad78a08f2b4aa0609be0b7adef6ff25d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for ovos-date-parser 0.41.1a5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page