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)

Parity guarantee

This engine reproduces the JS reference bit-exactly — instants, grains, and candidate order — across all 2,782 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nl2time-0.1.2.tar.gz (29.3 kB view details)

Uploaded Source

Built Distribution

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

nl2time-0.1.2-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file nl2time-0.1.2.tar.gz.

File metadata

  • Download URL: nl2time-0.1.2.tar.gz
  • Upload date:
  • Size: 29.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nl2time-0.1.2.tar.gz
Algorithm Hash digest
SHA256 63ce1e858eb5d26e7dd741f1b1da605108e6af23dd4d9cf96ab3990289daa709
MD5 3f52f7a39d009695eec7fd1e9325f240
BLAKE2b-256 02a98b3dd842958a4e9f4649008f209b40fcd2326ab463ab96d77b10d291f79c

See more details on using hashes here.

Provenance

The following attestation bundles were made for nl2time-0.1.2.tar.gz:

Publisher: release.yml on AndyFooBlah/nl2time

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nl2time-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: nl2time-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nl2time-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0010f07f16032512023cc1ef1ab99c4b8bd258399b14c05de3d0087c207eca91
MD5 60915f37c562c18c7508f42ccd2f83e4
BLAKE2b-256 56001642120cd9c2cb81ca531744a15491e83f76e14f2384b95e864a268ff846

See more details on using hashes here.

Provenance

The following attestation bundles were made for nl2time-0.1.2-py3-none-any.whl:

Publisher: release.yml on AndyFooBlah/nl2time

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

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