Supported Locales
whichtime supports parsing natural language dates in 12 languages.
Overview
| Code | Language | Native Name |
|---|---|---|
en | English | English |
de | German | Deutsch |
es | Spanish | Español |
fr | French | Français |
it | Italian | Italiano |
ja | Japanese | 日本語 |
nl | Dutch | Nederlands |
pt | Portuguese | Português |
ru | Russian | Русский |
sv | Swedish | Svenska |
uk | Ukrainian | Українська |
zh | Chinese | 中文 |
Feature Coverage
Not all locales have the same level of feature coverage. Here's an overview:
| Feature | en | de | es | fr | it | ja | nl | pt | ru | sv | uk | zh |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Casual dates | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Weekdays | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Month names | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Time expressions | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Relative (ago) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Relative (in X) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| ISO dates | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Slash dates | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Date Format Conventions
Different locales use different date format conventions:
| Locale | Format | Example |
|---|---|---|
| en (US) | MM/DD/YYYY | 12/25/2024 |
| de, es, fr, it, nl, pt, ru, sv, uk | DD/MM/YYYY | 25/12/2024 |
| ja, zh | YYYY/MM/DD | 2024/12/25 |
Quick Examples
rust
use whichtime_sys::{WhichTime, Locale};
// English
let en = WhichTime::with_locale(Locale::En);
en.parse_date("tomorrow at 3pm", None)?;
// German
let de = WhichTime::with_locale(Locale::De);
de.parse_date("morgen um 15 Uhr", None)?;
// Japanese
let ja = WhichTime::with_locale(Locale::Ja);
ja.parse_date("明日の午後3時", None)?;python
from whichtime import parse_with_locale, WhichTimeLocale
# English
parse_with_locale("tomorrow at 3pm", WhichTimeLocale.EN)
# German
parse_with_locale("morgen um 15 Uhr", WhichTimeLocale.DE)
# Japanese
parse_with_locale("明日の午後3時", WhichTimeLocale.JA)Adding New Locales
Want to add support for a new locale? See the Architecture guide for details on:
- Creating a dictionary file
- Implementing locale-specific parsers
- Adding tests
Contributions are welcome!