Skip to main content

cdate

Reproducible date formats for correspondence.

crates.io npm PyPI Rust API

Format a Gregorian calendar date without a timezone, operating-system locale, or network dependency. The same inputs produce the same text in Rust, JavaScript, Python, and Typst.

import { longDate } from '@corbet-labs/cdate';

longDate('de-ch', 2026, 9, 7);
// 7. September 2026

Install

Environment Command
Rust / Cargo cargo add cdate
Python / pip python -m pip install cdate
Python / uv uv add cdate
Node.js / npm npm install @corbet-labs/cdate
pnpm pnpm add @corbet-labs/cdate
Yarn yarn add @corbet-labs/cdate
Bun bun add @corbet-labs/cdate
Deno deno add npm:@corbet-labs/cdate

The 0.3.3 JavaScript distribution includes compiled ESM, CommonJS, TypeScript declarations, and a standalone browser module. Node.js 20+ is supported; no TypeScript loader is required.

// CommonJS
const { longDate } = require('@corbet-labs/cdate');
<script type="module">
  import { longDate } from 'https://cdn.jsdelivr.net/npm/@corbet-labs/cdate@0.3.3/dist/browser.js';
  console.log(longDate('de-ch', 2026, 9, 7));
</script>

Python 3.10+ packages are available on PyPI. See the installation guide for CLI commands and other distribution options. JSR publication and Typst availability are listed there explicitly.

Rust

use cdate::{long_date, month_year};

assert_eq!(long_date("de-ch", 2026, 9, 7).as_deref(), Some("7. September 2026"));
assert_eq!(month_year("en", 2026, 9).as_deref(), Some("September 2026"));

Typst in Rust hosts

The crate also ships the Typst package. Applications that embed the Typst compiler can register it from cdate::typst instead of downloading or vendoring a copy, so Rust and Typst always come from the same release. FILES holds package-relative paths (typst.toml, typst/date.typ, …) with their bytes; spec() is the import specification.

use cdate::typst::{FILES, NAME, NAMESPACE, VERSION, spec};

assert_eq!((NAMESPACE, NAME), ("preview", "cdate"));
assert_eq!(spec(), format!("@preview/cdate:{VERSION}"));
for (path, bytes) in FILES {
    // Serve `bytes` for `path` inside the package `spec()` in your Typst world.
    let _ = (path, bytes.len());
}

Documents then import the package as usual, for example #import "@preview/cdate:0.3.3": long-date.

Python

from cdate import long_date

assert long_date("de-ch", 2026, 9, 7) == '7. September 2026'

API

JavaScript / Python or Rust Example for de-ch
longDate / long_date 7. September 2026
mediumDate / medium_date 07.09.2026
shortDate / short_date 07.09.26
monthYear / month_year September 2026
isValidDate / is_valid_date Calendar-date validation

The ten date-table entries are de, de-at, de-ch, de-li, en, en-gb, en-us, fr, it, and rm. Matching is case-insensitive; other locales fall back through the base language to English. Impossible calendar dates return null/None. Inputs are calendar components, not timestamps. Other family libraries have broader locale coverage.

Correspondence family

Library Responsibility
cletter Compose the correspondence helpers
cgreet German salutations and titles
cfarewell Locale-specific closings
cdate Calendar-date formatting
cink Handwritten signature images

Development

Behavior is defined by the locale tables and shared conformance vectors. Rust, JavaScript, and Python run the same vectors. Selected CI checks exercise installed JavaScript tarballs, Python wheels and command-line entrypoints, and Typst packages. Release validation records the actual runtime and platform; Linux results do not establish native Windows or macOS coverage. All five Rust crates forbid unsafe code in their own source.

See the release guide for generation, verification, and publication commands.

License

Copyright 2026 Julian Y. Richard Corbet. The 0.3.3 release line is licensed under LGPL-3.0-only WITH LGPL-3.0-linking-exception, with the incorporated GPL version 3. Combined works may link statically or dynamically without relinking duties; library modifications stay LGPL. Applications can use a different license subject to the LGPL's conditions. Previously released and already prepared distributions retain their original grants. The installation examples above refer to those available releases; 0.3.3 is published to registries.

See the licensing notes for distribution conditions and retained notices. Contributions are subject to the Contributor License Agreement.

Metadata

Release files for cdate 0.3.3

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

Source distribution (sdist)

Source distribution for cdate 0.3.3
File Size Uploaded Provenance Actions
cdate-0.3.3.tar.gz 39.0 kB Without provenance Details for cdate-0.3.3.tar.gz

Built distribution (wheel)

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

Total release size: 77.0 kB

Release files / cdate-0.3.3.tar.gz

Download URL cdate-0.3.3.tar.gz
Size 39.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d2ae5e04ac9a399ddf156076cdfe22bd316ba2365c2103257ee3e6e8e383f738
BLAKE2b-256 checksum
How to use checksums
836af89cff7a992c927e108994cbe354aba48123b4b428e1582cf44f4e5dfea2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"26.11","id":"zokor","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / cdate-0.3.3-py3-none-any.whl

Download URL cdate-0.3.3-py3-none-any.whl
Size 38.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d29a5f76e2a389ec93607a5a797490ad7cef6c823e3d1846fdb3d11eda356435
BLAKE2b-256 checksum
How to use checksums
c225fb49c869badae8e7b6f85503aa71ad34862223a72536a9618697c3000bc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"26.11","id":"zokor","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for cdate 0.3.3

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.

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