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.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/cdate@0.2.1/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.

Release files for cdate 0.3.1

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.1
File Size Uploaded
cdate-0.3.1.tar.gz 38.2 kB Details

Built distribution (wheel)

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

Total release size: 76.4 kB

Release files / cdate-0.3.1.tar.gz

Download URL cdate-0.3.1.tar.gz
Size 38.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2693b82867098992f9c146c5099cb503569be8d7bbf36bb407e6c388d8f2e3c6
BLAKE2b-256 checksum
How to use checksums
4f5950a1fc395635980a294db6ba3cd6bfda8659e0bb75dd4db598c931421b80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"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.1-py3-none-any.whl

Download URL cdate-0.3.1-py3-none-any.whl
Size 38.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
967d963e90e9bec7c13b81bfc3730fc79253e017f40b32bf3c502f9bc94f028b
BLAKE2b-256 checksum
How to use checksums
3c8e8d61417f8b34647671c4da17045b03455a81803506043a413af4bd0c5204
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release 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