Skip to content

whichtimeNatural Language Date Parsing

High-performance parsing for Rust, Swift, Kotlin, and Python

Quick Example

rust
use whichtime_sys::WhichTime;

let parser = WhichTime::new();
let date = parser.parse_date("tomorrow at 3pm", None)?;
println!("{}", date.unwrap().to_rfc3339());
swift
import WhichtimeCore

let results = try parse(text: "tomorrow at 3pm")
if let millis = results.first?.dateMillis {
    let date = Date(timeIntervalSince1970: Double(millis) / 1000.0)
    print(date)
}
kotlin
import works.transcode.whichtime.*

val results = parse("tomorrow at 3pm")
results.firstOrNull()?.dateMillis?.let { millis ->
    println(java.util.Date(millis))
}
python
from whichtime import parse
from datetime import datetime

results = parse("tomorrow at 3pm")
if results and results[0].date_millis:
    dt = datetime.fromtimestamp(results[0].date_millis / 1000.0)
    print(dt)

Supported Expressions

CategoryExamples
Casual datestoday, tomorrow, yesterday
Relative datesin 2 hours, 3 days ago, next week
WeekdaysMonday, next Friday, last Tuesday
Explicit dates2024-12-25, December 25th
Time expressions3pm, 15:30, noon, midnight
Combinedtomorrow at 3pm, next Monday morning

Released under the MIT License.