Skip to main content

Crate dateoxide_core

Crate dateoxide_core 

Source
Expand description

High-performance, low-memory, zero-ReDoS multilingual natural-language date parser in pure Rust.

dateoxide-core powers the Python package dateoxide across 205 languages, non-Gregorian calendars (official Saudi Umm al-Qura Hijri, Jalali, Minguo, French Republican), time spans, and parallel batch parsing.

§Quick Start

use dateoxide_core::{calendars, parse, parse_batch, parse_with_settings, search::search_dates, settings::Settings};
use chrono::{Datelike, NaiveDate, NaiveDateTime};

// Fast ISO-8601, RFC-2822/3339, and ISO week date parsing
let dt = parse("2026-11-26").unwrap();
assert_eq!(dt.naive_local().date(), NaiveDate::from_ymd_opt(2026, 11, 26).unwrap());

let iso_week = parse("2026-W48-4").unwrap();
assert_eq!(iso_week.naive_local().date(), NaiveDate::from_ymd_opt(2026, 11, 26).unwrap());

// Multilingual natural-language & relative parsing with fixed RELATIVE_BASE
let mut settings = Settings::default();
settings.relative_base = Some(
    NaiveDateTime::parse_from_str("2026-11-26 15:00:00", "%Y-%m-%d %H:%M:%S").unwrap(),
);
let tr = parse_with_settings("3 gün önce", &settings).unwrap();
assert_eq!(tr.naive_local().day(), 23);

// Free-form text extraction and parallel batch parsing
let found = search_dates("Meeting on 12 December 2025", &settings);
assert_eq!(found.len(), 1);

let batch = parse_batch(&["2026-11-26", "vor 2 Wochen", "not a date"], &settings);
assert!(batch[0].is_some() && batch[1].is_some() && batch[2].is_none());

// Non-Gregorian calendar conversion (official Umm al-Qura Hijri)
let hijri = calendars::parse_hijri("1446/09/01", &settings);
assert_eq!(hijri.date_obj.unwrap().naive_local().date(), NaiveDate::from_ymd_opt(2025, 3, 1).unwrap());

Modules§

absolute
calendars
fast_path
locale
ranges
relative
search
settings
time_spans
timezone
umm_al_qura

Functions§

get_date_data
Full dateparser.date.DateDataParser.get_date_data equivalent returning DateData { date_obj, period, locale, parts, part_of_day }.
parse
Parse a date string using default settings.
parse_batch
Parallel batch parsing powered by Rayon across all available CPU cores (falls back to sequential iteration when the rayon feature is disabled).
parse_batch_opt
Nullable parallel batch parsing (Option<String> inputs skip None cleanly).
parse_date_range
Parse natural-language or numeric date/time ranges into (start, end).
parse_freshness
Relative-only parser backing dateparser.freshness_date_parser.FreshnessDateDataParser.
parse_with_settings
Parse a date string using explicit Settings.
search_dates
Find and parse all date expressions embedded in free-form text.
search_dates_full
Find and parse all date expressions returning full match metadata.
search_dates_with_locale
Find and parse all date expressions embedded in free-form text, including detected locale code.