rosetta_date/lib.rs
1//! # rosetta-date
2//!
3//! A powerful, multi-language, multi-format timezone-aware date parser written
4//! in Rust. Inspired by Python's `dateparser`, it can parse natural-language
5//! expressions ("2 hours ago", "昨天", "January 15th 2025") as well as all
6//! common machine-readable formats (ISO 8601, RFC 2822/3339, …).
7//!
8//! ## Features
9//!
10//! | Feature | Description |
11//! |------------------|------------------------------------------|
12//! | `time-backend` | Use the `time` crate (default) |
13//! | `chrono-backend` | Use the `chrono` crate |
14//! | `lang-en` | English language data (default) |
15//! | `lang-zh` | Chinese language data |
16//! | `all-languages` | Enable all language packs |
17//! | `serde` | Serde serialisation support |
18//! | `wasm` | WASM / `wasm-bindgen` bindings |
19//!
20//! ## Quick Start
21//!
22//! ```rust
23//! use rosetta_date::{parse, RosettaDateTime};
24//!
25//! // Standard format
26//! let dt = parse("2023-10-15T12:30:45+08:00").unwrap();
27//! assert_eq!(dt.year(), 2023);
28//!
29//! // Natural language (requires a language feature)
30//! let dt = parse("3 hours ago").unwrap();
31//!
32//! // Formatting
33//! use rosetta_date::format_datetime;
34//! let s = format_datetime(&dt, "%Y-%m-%d %H:%M:%S", None);
35//! ```
36
37pub mod dateparser;
38pub mod datetime;
39pub mod delta;
40pub mod error;
41pub mod formatter;
42pub mod i18n;
43pub mod nlp;
44pub mod parser;
45pub mod timezone;
46pub mod wasm;
47
48// ── Re-exports ────────────────────────────────────────────────────────
49
50pub use datetime::RosettaDateTime;
51pub use delta::RosettaDelta;
52pub use error::{Result, RosettaError};
53pub use formatter::{format_datetime, time_ago};
54pub use parser::{ParseOptions, parse, parse_with_options};
55pub use timezone::TzOffset;