High-performance natural language date parsing in Rust.
whichtime ships three intentional public Rust packages:
whichtime: the recommended high-level Rust APIwhichtime-sys: the lower-level parsing engine cratewhichtime-cli: a small CLI for quick parsing and smoke tests
Swift, Kotlin, and Python bindings are available as preview/source-build integrations until further testing is complete.
- Guide: https://transcodeworks.github.io/whichtime/
- Rust docs (
whichtime): https://docs.rs/whichtime - Rust docs (
whichtime-sys): https://docs.rs/whichtime-sys
Add whichtime to your Rust project:
[dependencies]
whichtime = "0.1"use whichtime::WhichTime;
fn main() -> whichtime::Result<()> {
let parser = WhichTime::new();
if let Some(date) = parser.parse_date("tomorrow at 3pm", None)? {
println!("{}", date.to_rfc3339());
}
if let Some(date) = parser.fr().parse_date("demain matin", None)? {
println!("{}", date.to_rfc3339());
}
// Using a reference date
let reference = chrono::Utc::now();
if let Some(date) = parser.parse_date("tomorrow at 3pm", Some(reference))? {
println!("{}", date.to_rfc3339());
}
Ok(())
}Use whichtime-sys when you want direct access to the lower-level engine, or when you need to build a custom parser pipeline.
Install the CLI with:
cargo install whichtime-cliwhichtime can parse casual dates, relative dates, weekdays, explicit dates, time expressions, and date ranges such as:
tomorrow at 3pmin 2 hoursnext FridayDecember 25th, 2026Monday to Friday
The Rust crates currently support these locales:
enEnglishdeGermanesSpanishfrFrenchitItalianjaJapanesenlDutchptPortugueseruRussiansvSwedishukUkrainianzhChinese
whichtime: recommended high-level Rust API for application codewhichtime-sys: lower-level parsing engine for direct parser access and custom integration workwhichtime-cli: command-line interface that prints the first parsed timestamp as RFC 3339 in UTCwhichtime-ffi: internal crate used for UniFFI bindings and shared cross-language transport types
The repository also contains Swift, Kotlin, and Python bindings.
- Swift: build the XCFramework locally with
./common/build-ios.sh - Kotlin: generate bindings locally with
./common/build-kotlin.sh - Python: build and install locally with
./common/build-python.sh
cargo test --workspace --all-features
cargo fmt --all -- --check
cargo clippy --workspace --all-features -- -D warningsTo validate publishable crates locally:
cargo package -p whichtime-sys
cargo package --list -p whichtime
cargo package --list -p whichtime-cliMIT. See LICENSE.
- chrono-node — The JavaScript library that inspired this project
- UniFFI — Mozilla's FFI bindings generator
- Ferrostar — Inspiration for project structure and build system