Skip to main content

nl2time (Python)

Deterministic resolution of temporal-expression IR — the Python port of nl2time, a bidirectional natural language ⇄ date/time library built around a JSON intermediate representation (TimeExpr).

Scope of this release: the language-neutral core. IR validation, TimeContext (reference instant, IANA timezone, locale-derived week/date policy, ambiguity knobs), and the full deterministic engine resolve() — every operator including calendar snapping, DST-correct offsets, holidays (computed Easter), business-day spans, and ordered ambiguity candidates. Natural-language parsing and rendering are not yet ported; today the expected producers of IR are the JS parser, an LLM emitting schema-constrained IR, or your own code. Time model: whenever (Temporal-inspired).

from nl2time import TimeContext, resolve

ctx = TimeContext.make({
    "now": "2026-07-20T17:00:00Z",
    "timeZone": "America/Los_Angeles",
    "locale": "en-US",
})

# "last week" as IR (e.g. produced by the JS parser or an LLM):
expr = {
    "op": "snap",
    "base": {"op": "offset", "base": {"op": "now"}, "amount": -1, "unit": "week"},
    "unit": "week",
}
resolve(expr, ctx)["candidates"][0]
# {"kind": "interval", "start": Instant("2026-07-12 07:00:00Z"),
#  "end": Instant("2026-07-19 07:00:00Z"), "grain": "week"}
# (values are `whenever.Instant`; candidates are ordered, ambiguity is data;
#  an open-start range such as {"op": "until", ...} for a past boundary has "start": None)

Parity guarantee

This engine reproduces the JS reference bit-exactly — instants, grains, and candidate order — across all 2,827 machine-generated engine-parity fixtures derived from the project's six-language conformance corpora, enforced in CI on every commit. Spec: ir-spec.md; strategy: porting.md; test-data provenance: corpus/ATTRIBUTIONS.md.

MIT.

Metadata

Release files for nl2time 0.2.0

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

Source distribution (sdist)

Source distribution for nl2time 0.2.0
File Size Uploaded Provenance Actions
nl2time-0.2.0.tar.gz 33.6 kB With provenance Details for nl2time-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nl2time 0.2.0
File Interpreter ABI Platform Actions
nl2time-0.2.0-py3-none-any.whl Python 3 none any Details for nl2time-0.2.0-py3-none-any.whl

Total release size: 54.4 kB

Release files / nl2time-0.2.0.tar.gz

Download URL nl2time-0.2.0.tar.gz
Size 33.6 kB
Tags Source
SHA-256 checksum
How to use checksums
abcf47845b2d0d6e86fb960fbc4c6d8bdef564c9c8c56b37a46629f3f6ec22c6
BLAKE2b-256 checksum
How to use checksums
3c4b4efa9336ed61e1cab50ee5fa05d1a4850133ff9933034bb85d76103745fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Release files / nl2time-0.2.0-py3-none-any.whl

Download URL nl2time-0.2.0-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c25992e5a65c55bb06e559e424a9d130d25e34fd9e2e6d633b5f66f1b797ba84
BLAKE2b-256 checksum
How to use checksums
0d5b6347d7a3a8708fc94aec18cb947addb2ed87441072c2d43ec26cfe52007f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Security for nl2time 0.2.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for nl2time-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

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.

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