Deterministic temporal-expression IR engine — Python port of the nl2time natural language ⇄ date/time library
Project description
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)
Parity guarantee
This engine reproduces the JS reference bit-exactly — instants, grains, and candidate order — across all 2,760 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nl2time-0.1.1.tar.gz.
File metadata
- Download URL: nl2time-0.1.1.tar.gz
- Upload date:
- Size: 29.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d90857ea158fdd83645bedd7210c1ae126de5323a4b489258f87a10588e4022
|
|
| MD5 |
b2b0422a16ca4068a3a9d36cc4277627
|
|
| BLAKE2b-256 |
6b3901670014bddf35a104b0135a6f71ed434922a95a072e576197c2554cc6ee
|
Provenance
The following attestation bundles were made for nl2time-0.1.1.tar.gz:
Publisher:
release.yml on AndyFooBlah/nl2time
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nl2time-0.1.1.tar.gz -
Subject digest:
8d90857ea158fdd83645bedd7210c1ae126de5323a4b489258f87a10588e4022 - Sigstore transparency entry: 2256723233
- Sigstore integration time:
-
Permalink:
AndyFooBlah/nl2time@0315a4487bbbfc00dcf6f5b4e1bd4d1f4322fd5c -
Branch / Tag:
refs/tags/py-v0.1.1 - Owner: https://github.com/AndyFooBlah
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0315a4487bbbfc00dcf6f5b4e1bd4d1f4322fd5c -
Trigger Event:
release
-
Statement type:
File details
Details for the file nl2time-0.1.1-py3-none-any.whl.
File metadata
- Download URL: nl2time-0.1.1-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df037ae586fd40c53ee5de18d60bf3e3a8fb23e62a5abc226d6494ef05698ea1
|
|
| MD5 |
9e80ec353df8cdbf9dcdc3254df8a256
|
|
| BLAKE2b-256 |
94dc286b6506d519f158e3eba47f0274a3713e8b028237fd1ff202dfe24dd303
|
Provenance
The following attestation bundles were made for nl2time-0.1.1-py3-none-any.whl:
Publisher:
release.yml on AndyFooBlah/nl2time
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nl2time-0.1.1-py3-none-any.whl -
Subject digest:
df037ae586fd40c53ee5de18d60bf3e3a8fb23e62a5abc226d6494ef05698ea1 - Sigstore transparency entry: 2256723246
- Sigstore integration time:
-
Permalink:
AndyFooBlah/nl2time@0315a4487bbbfc00dcf6f5b4e1bd4d1f4322fd5c -
Branch / Tag:
refs/tags/py-v0.1.1 - Owner: https://github.com/AndyFooBlah
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0315a4487bbbfc00dcf6f5b4e1bd4d1f4322fd5c -
Trigger Event:
release
-
Statement type: