@corbet-labs/cdate
v0.3.1
Published
Deterministic locale-correct date formats for formal correspondence. Mirrors the cdate Rust crate release line.
Downloads
829
Maintainers
Readme
cdate
Reproducible date formats for correspondence.
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 2026Install
| 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.2.1 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/[email protected]/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"));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.0 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.0 has not yet been published to registries.
See the licensing notes for distribution conditions and retained notices.
