dateoxide 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dateoxide-0.1.0 → dateoxide-0.2.0}/Cargo.lock +2 -2
- {dateoxide-0.1.0 → dateoxide-0.2.0}/Cargo.toml +1 -1
- {dateoxide-0.1.0 → dateoxide-0.2.0}/PKG-INFO +45 -5
- {dateoxide-0.1.0 → dateoxide-0.2.0}/README.md +44 -4
- {dateoxide-0.1.0 → dateoxide-0.2.0}/crates/dateoxide-core/Cargo.toml +15 -1
- dateoxide-0.2.0/crates/dateoxide-core/README.md +243 -0
- dateoxide-0.2.0/crates/dateoxide-core/benches/parse_bench.rs +51 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/crates/dateoxide-core/src/fast_path.rs +206 -16
- {dateoxide-0.1.0 → dateoxide-0.2.0}/crates/dateoxide-core/src/lib.rs +167 -15
- {dateoxide-0.1.0 → dateoxide-0.2.0}/crates/dateoxide-core/src/locale/mod.rs +25 -3
- {dateoxide-0.1.0 → dateoxide-0.2.0}/crates/dateoxide-core/src/relative.rs +370 -31
- {dateoxide-0.1.0 → dateoxide-0.2.0}/crates/dateoxide-core/src/search.rs +86 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/crates/dateoxide-core/src/time_spans.rs +46 -1
- {dateoxide-0.1.0 → dateoxide-0.2.0}/crates/dateoxide-core/src/timezone.rs +15 -8
- {dateoxide-0.1.0 → dateoxide-0.2.0}/crates/dateoxide-py/src/lib.rs +146 -44
- {dateoxide-0.1.0 → dateoxide-0.2.0}/pyproject.toml +1 -1
- {dateoxide-0.1.0 → dateoxide-0.2.0}/python/dateoxide/conf.py +1 -5
- dateoxide-0.2.0/python/dateoxide/py.typed +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/LICENSE +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/NOTICE +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/crates/dateoxide-core/build.rs +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/crates/dateoxide-core/data/locales.json +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/crates/dateoxide-core/src/absolute.rs +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/crates/dateoxide-core/src/calendars.rs +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/crates/dateoxide-core/src/locale/schema.rs +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/crates/dateoxide-core/src/settings.rs +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/crates/dateoxide-core/src/umm_al_qura.rs +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/crates/dateoxide-py/Cargo.toml +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/python/dateoxide/__init__.py +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/python/dateoxide/__init__.pyi +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/python/dateoxide/calendars/__init__.py +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/python/dateoxide/calendars/french_republican.py +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/python/dateoxide/calendars/hijri.py +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/python/dateoxide/calendars/jalali.py +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/python/dateoxide/calendars/minguo.py +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/python/dateoxide/date.py +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/python/dateoxide/freshness_date_parser.py +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/python/dateoxide/search.py +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/python/dateoxide/timezone_parser.py +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/python/dateoxide/utils/__init__.py +0 -0
- {dateoxide-0.1.0 → dateoxide-0.2.0}/python/dateoxide/utils/time_spans.py +0 -0
|
@@ -247,7 +247,7 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
|
|
|
247
247
|
|
|
248
248
|
[[package]]
|
|
249
249
|
name = "dateoxide-core"
|
|
250
|
-
version = "0.
|
|
250
|
+
version = "0.2.0"
|
|
251
251
|
dependencies = [
|
|
252
252
|
"aho-corasick",
|
|
253
253
|
"chrono",
|
|
@@ -263,7 +263,7 @@ dependencies = [
|
|
|
263
263
|
|
|
264
264
|
[[package]]
|
|
265
265
|
name = "dateoxide-py"
|
|
266
|
-
version = "0.
|
|
266
|
+
version = "0.2.0"
|
|
267
267
|
dependencies = [
|
|
268
268
|
"chrono",
|
|
269
269
|
"chrono-tz",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dateoxide
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Classifier: Development Status :: 4 - Beta
|
|
5
5
|
Classifier: Intended Audience :: Developers
|
|
6
6
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -33,15 +33,27 @@ Project-URL: Repository, https://github.com/Pastalikek65/dateoxide
|
|
|
33
33
|
|
|
34
34
|
# dateoxide
|
|
35
35
|
|
|
36
|
+
[](https://github.com/Pastalikek65/dateoxide/actions/workflows/ci.yml)
|
|
37
|
+
[](https://pypi.org/project/dateoxide/)
|
|
38
|
+
[](https://crates.io/crates/dateoxide-core)
|
|
39
|
+
[](https://docs.rs/dateoxide-core)
|
|
40
|
+
[](https://pypi.org/project/dateoxide/)
|
|
41
|
+
[](LICENSE)
|
|
42
|
+
|
|
36
43
|
**Blazing-fast, low-memory, multilingual natural-language date parser written in Rust — a full-featured drop-in replacement for Python's [`dateparser`](https://github.com/scrapinghub/dateparser).**
|
|
37
44
|
|
|
45
|
+
```bash
|
|
46
|
+
pip install dateoxide # Python (pre-built cp39-abi3 wheels: Linux, macOS, Windows)
|
|
47
|
+
cargo add dateoxide-core # Pure Rust crate
|
|
48
|
+
```
|
|
49
|
+
|
|
38
50
|
`dateoxide` replaces runtime Python regex compilation and 205 dynamically imported locale modules with a compiled zero-backtracking Rust engine (`dateoxide-core`) exposed to Python via **PyO3 + maturin**.
|
|
39
51
|
|
|
40
52
|
- **108x – 7,210x faster** single-threaded parsing (`977x – 36,034x` with GIL-free parallel `parse_batch`)
|
|
41
53
|
- **7.4x lower memory footprint** (`+6.93 MB` vs `+51.56 MB` RSS delta across 205 languages)
|
|
42
54
|
- **17.3x faster cold import** (`5.21 ms` vs `90.22 ms`) via PEP 562 lazy submodules
|
|
43
55
|
- **Zero ReDoS** — linear-time parsing with zero catastrophic backtracking
|
|
44
|
-
- **
|
|
56
|
+
- **3,102+ automated tests passing in <4s** — including 1,010 upstream `scrapinghub/dateparser` test vectors, exact `datetime` assertions across 205 languages, `dateparser` compatibility & fuzzing matrices, known `dateparser` bug regressions, and 3,792 official Saudi Umm al-Qura Hijri dates
|
|
45
57
|
- **Official Saudi Umm al-Qura Hijri Calendar (1343–1500 AH)** embedded directly in pure Rust (3,792/3,792 month-start & month-end dates verified against `hijridate`, with zero runtime dependencies), plus Jalali, Minguo, and French Republican calendars
|
|
46
58
|
- **Complete `dateparser` feature parity**:
|
|
47
59
|
- `parse()`, `DateDataParser` (`get_date_data`, `get_date_tuple`, `parts`, `part_of_day`), `search_dates(..., add_period=..., add_detected_language=...)`
|
|
@@ -72,11 +84,26 @@ Measured with [`benchmarks/bench_vs_dateparser.py`](benchmarks/bench_vs_datepars
|
|
|
72
84
|
| **Multilingual Natural Language (Auto)** | 1,239 /s | **133,916 /s** *(108x)* | **160,849 /s** *(130x)* | **1,211,446 /s** *(977x)* |
|
|
73
85
|
| **Invalid / Non-Date Text (Worst Case)** | 60 /s | **196,333 /s** *(3,279x)* | **262,130 /s** *(4,378x)* | **2,157,386 /s** *(36,034x)* |
|
|
74
86
|
|
|
75
|
-
Reproduce locally:
|
|
87
|
+
Reproduce locally (or run the accuracy-checked torture suite):
|
|
76
88
|
```bash
|
|
77
89
|
python benchmarks/bench_vs_dateparser.py
|
|
90
|
+
python benchmarks/torture_benchmark.py --json
|
|
78
91
|
```
|
|
79
92
|
|
|
93
|
+
### Independent Torture Benchmark (Accuracy, ReDoS & Known Differences)
|
|
94
|
+
|
|
95
|
+
Measured with [`benchmarks/torture_benchmark.py`](benchmarks/torture_benchmark.py) across 79 adversarial cases (multilingual casing/scripts, fractional/conversational phrases, month-end clamping, leap/ISO-week traps, RFC/CLF/DST, false-positive traps), dirty `search_dates`, and 6 ReDoS stress bombs (`dateoxide 0.2.0` vs `dateparser 1.5.1` on Python 3.12.10):
|
|
96
|
+
|
|
97
|
+
| Metric | `dateparser 1.5.1` | `dateoxide 0.2.0` |
|
|
98
|
+
| :--- | ---: | ---: |
|
|
99
|
+
| **Torture accuracy (79 hard cases)** | 66 / 79 (`4,243.30 ms`) | **78 / 79 (`1.60 ms`)** |
|
|
100
|
+
| **Dirty `search_dates` (6 docs)** | 4 / 6 (`1,885.91 ms`) | **6 / 6 (`0.48 ms`)** |
|
|
101
|
+
| **6 ReDoS stress bombs (3k–5k chars)** | `20,111.62 ms` | **`5.46 ms`** |
|
|
102
|
+
| **Full 79-case isolated throughput & RSS** | `57.4 /s` (`+64.52 MB`) | **`20,629.9 /s` (`+10.24 MB`)** *(359.4x)* |
|
|
103
|
+
|
|
104
|
+
**Transparently noted difference (`1 / 79`):**
|
|
105
|
+
- `"2026-13-01"` swaps to `2026-01-13` under default `STRICT_DATE_ORDER="none"` in **both** `dateoxide` and `dateparser` (set `STRICT_DATE_ORDER="all"` to reject invalid month indices strictly).
|
|
106
|
+
|
|
80
107
|
---
|
|
81
108
|
|
|
82
109
|
## Upstream `dateparser` Bugs Fixed / Avoided
|
|
@@ -177,6 +204,18 @@ dates = ["2026-11-26", "3 gün önce", "vor 2 Wochen", "not a date"] * 25_000
|
|
|
177
204
|
results = dateoxide.parse_batch(dates) # Runs across all CPU cores via Rayon
|
|
178
205
|
```
|
|
179
206
|
|
|
207
|
+
### Real-World Examples (`examples/`)
|
|
208
|
+
|
|
209
|
+
- [`examples/telegram_reminder_bot.py`](examples/telegram_reminder_bot.py) — Multilingual Telegram reminder parser & UTC scheduler
|
|
210
|
+
- [`examples/log_pipeline.py`](examples/log_pipeline.py) — Mixed Nginx CLF / RFC 3339 / bracketed log normalizer with `parse_batch`
|
|
211
|
+
- [`examples/big_data_parser.py`](examples/big_data_parser.py) — 50,000-record multilingual ETL throughput & RSS demo
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
python examples/telegram_reminder_bot.py
|
|
215
|
+
python examples/log_pipeline.py
|
|
216
|
+
python examples/big_data_parser.py
|
|
217
|
+
```
|
|
218
|
+
|
|
180
219
|
---
|
|
181
220
|
|
|
182
221
|
## Standalone Rust Usage (`dateoxide-core`)
|
|
@@ -215,11 +254,12 @@ maturin develop --release
|
|
|
215
254
|
# Run Rust core tests
|
|
216
255
|
cargo test -p dateoxide-core --release
|
|
217
256
|
|
|
218
|
-
# Run full
|
|
257
|
+
# Run full 3,000+ test suite (including parity matrix, fuzzing & Umm al-Qura Hijri)
|
|
219
258
|
pytest -v
|
|
220
259
|
|
|
221
|
-
# Run head-to-head
|
|
260
|
+
# Run standard & torture head-to-head benchmarks vs dateparser
|
|
222
261
|
python benchmarks/bench_vs_dateparser.py
|
|
262
|
+
python benchmarks/torture_benchmark.py
|
|
223
263
|
```
|
|
224
264
|
|
|
225
265
|
Automated PyPI (OIDC Trusted Publishing) and crates.io multi-platform wheel builds trigger on release tags:
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
# dateoxide
|
|
2
2
|
|
|
3
|
+
[](https://github.com/Pastalikek65/dateoxide/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/dateoxide/)
|
|
5
|
+
[](https://crates.io/crates/dateoxide-core)
|
|
6
|
+
[](https://docs.rs/dateoxide-core)
|
|
7
|
+
[](https://pypi.org/project/dateoxide/)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
3
10
|
**Blazing-fast, low-memory, multilingual natural-language date parser written in Rust — a full-featured drop-in replacement for Python's [`dateparser`](https://github.com/scrapinghub/dateparser).**
|
|
4
11
|
|
|
12
|
+
```bash
|
|
13
|
+
pip install dateoxide # Python (pre-built cp39-abi3 wheels: Linux, macOS, Windows)
|
|
14
|
+
cargo add dateoxide-core # Pure Rust crate
|
|
15
|
+
```
|
|
16
|
+
|
|
5
17
|
`dateoxide` replaces runtime Python regex compilation and 205 dynamically imported locale modules with a compiled zero-backtracking Rust engine (`dateoxide-core`) exposed to Python via **PyO3 + maturin**.
|
|
6
18
|
|
|
7
19
|
- **108x – 7,210x faster** single-threaded parsing (`977x – 36,034x` with GIL-free parallel `parse_batch`)
|
|
8
20
|
- **7.4x lower memory footprint** (`+6.93 MB` vs `+51.56 MB` RSS delta across 205 languages)
|
|
9
21
|
- **17.3x faster cold import** (`5.21 ms` vs `90.22 ms`) via PEP 562 lazy submodules
|
|
10
22
|
- **Zero ReDoS** — linear-time parsing with zero catastrophic backtracking
|
|
11
|
-
- **
|
|
23
|
+
- **3,102+ automated tests passing in <4s** — including 1,010 upstream `scrapinghub/dateparser` test vectors, exact `datetime` assertions across 205 languages, `dateparser` compatibility & fuzzing matrices, known `dateparser` bug regressions, and 3,792 official Saudi Umm al-Qura Hijri dates
|
|
12
24
|
- **Official Saudi Umm al-Qura Hijri Calendar (1343–1500 AH)** embedded directly in pure Rust (3,792/3,792 month-start & month-end dates verified against `hijridate`, with zero runtime dependencies), plus Jalali, Minguo, and French Republican calendars
|
|
13
25
|
- **Complete `dateparser` feature parity**:
|
|
14
26
|
- `parse()`, `DateDataParser` (`get_date_data`, `get_date_tuple`, `parts`, `part_of_day`), `search_dates(..., add_period=..., add_detected_language=...)`
|
|
@@ -39,11 +51,26 @@ Measured with [`benchmarks/bench_vs_dateparser.py`](benchmarks/bench_vs_datepars
|
|
|
39
51
|
| **Multilingual Natural Language (Auto)** | 1,239 /s | **133,916 /s** *(108x)* | **160,849 /s** *(130x)* | **1,211,446 /s** *(977x)* |
|
|
40
52
|
| **Invalid / Non-Date Text (Worst Case)** | 60 /s | **196,333 /s** *(3,279x)* | **262,130 /s** *(4,378x)* | **2,157,386 /s** *(36,034x)* |
|
|
41
53
|
|
|
42
|
-
Reproduce locally:
|
|
54
|
+
Reproduce locally (or run the accuracy-checked torture suite):
|
|
43
55
|
```bash
|
|
44
56
|
python benchmarks/bench_vs_dateparser.py
|
|
57
|
+
python benchmarks/torture_benchmark.py --json
|
|
45
58
|
```
|
|
46
59
|
|
|
60
|
+
### Independent Torture Benchmark (Accuracy, ReDoS & Known Differences)
|
|
61
|
+
|
|
62
|
+
Measured with [`benchmarks/torture_benchmark.py`](benchmarks/torture_benchmark.py) across 79 adversarial cases (multilingual casing/scripts, fractional/conversational phrases, month-end clamping, leap/ISO-week traps, RFC/CLF/DST, false-positive traps), dirty `search_dates`, and 6 ReDoS stress bombs (`dateoxide 0.2.0` vs `dateparser 1.5.1` on Python 3.12.10):
|
|
63
|
+
|
|
64
|
+
| Metric | `dateparser 1.5.1` | `dateoxide 0.2.0` |
|
|
65
|
+
| :--- | ---: | ---: |
|
|
66
|
+
| **Torture accuracy (79 hard cases)** | 66 / 79 (`4,243.30 ms`) | **78 / 79 (`1.60 ms`)** |
|
|
67
|
+
| **Dirty `search_dates` (6 docs)** | 4 / 6 (`1,885.91 ms`) | **6 / 6 (`0.48 ms`)** |
|
|
68
|
+
| **6 ReDoS stress bombs (3k–5k chars)** | `20,111.62 ms` | **`5.46 ms`** |
|
|
69
|
+
| **Full 79-case isolated throughput & RSS** | `57.4 /s` (`+64.52 MB`) | **`20,629.9 /s` (`+10.24 MB`)** *(359.4x)* |
|
|
70
|
+
|
|
71
|
+
**Transparently noted difference (`1 / 79`):**
|
|
72
|
+
- `"2026-13-01"` swaps to `2026-01-13` under default `STRICT_DATE_ORDER="none"` in **both** `dateoxide` and `dateparser` (set `STRICT_DATE_ORDER="all"` to reject invalid month indices strictly).
|
|
73
|
+
|
|
47
74
|
---
|
|
48
75
|
|
|
49
76
|
## Upstream `dateparser` Bugs Fixed / Avoided
|
|
@@ -144,6 +171,18 @@ dates = ["2026-11-26", "3 gün önce", "vor 2 Wochen", "not a date"] * 25_000
|
|
|
144
171
|
results = dateoxide.parse_batch(dates) # Runs across all CPU cores via Rayon
|
|
145
172
|
```
|
|
146
173
|
|
|
174
|
+
### Real-World Examples (`examples/`)
|
|
175
|
+
|
|
176
|
+
- [`examples/telegram_reminder_bot.py`](examples/telegram_reminder_bot.py) — Multilingual Telegram reminder parser & UTC scheduler
|
|
177
|
+
- [`examples/log_pipeline.py`](examples/log_pipeline.py) — Mixed Nginx CLF / RFC 3339 / bracketed log normalizer with `parse_batch`
|
|
178
|
+
- [`examples/big_data_parser.py`](examples/big_data_parser.py) — 50,000-record multilingual ETL throughput & RSS demo
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
python examples/telegram_reminder_bot.py
|
|
182
|
+
python examples/log_pipeline.py
|
|
183
|
+
python examples/big_data_parser.py
|
|
184
|
+
```
|
|
185
|
+
|
|
147
186
|
---
|
|
148
187
|
|
|
149
188
|
## Standalone Rust Usage (`dateoxide-core`)
|
|
@@ -182,11 +221,12 @@ maturin develop --release
|
|
|
182
221
|
# Run Rust core tests
|
|
183
222
|
cargo test -p dateoxide-core --release
|
|
184
223
|
|
|
185
|
-
# Run full
|
|
224
|
+
# Run full 3,000+ test suite (including parity matrix, fuzzing & Umm al-Qura Hijri)
|
|
186
225
|
pytest -v
|
|
187
226
|
|
|
188
|
-
# Run head-to-head
|
|
227
|
+
# Run standard & torture head-to-head benchmarks vs dateparser
|
|
189
228
|
python benchmarks/bench_vs_dateparser.py
|
|
229
|
+
python benchmarks/torture_benchmark.py
|
|
190
230
|
```
|
|
191
231
|
|
|
192
232
|
Automated PyPI (OIDC Trusted Publishing) and crates.io multi-platform wheel builds trigger on release tags:
|
|
@@ -4,14 +4,24 @@ version.workspace = true
|
|
|
4
4
|
edition.workspace = true
|
|
5
5
|
license.workspace = true
|
|
6
6
|
repository.workspace = true
|
|
7
|
+
homepage = "https://github.com/Pastalikek65/dateoxide"
|
|
8
|
+
documentation = "https://docs.rs/dateoxide-core"
|
|
9
|
+
readme = "README.md"
|
|
7
10
|
description = "High-performance, low-memory multilingual natural-language date parser core in Rust."
|
|
11
|
+
keywords = ["date", "datetime", "parser", "multilingual", "nlp"]
|
|
12
|
+
categories = ["date-and-time", "internationalization", "parsing", "text-processing"]
|
|
13
|
+
|
|
14
|
+
[features]
|
|
15
|
+
default = ["rayon", "calendars"]
|
|
16
|
+
rayon = ["dep:rayon"]
|
|
17
|
+
calendars = []
|
|
8
18
|
|
|
9
19
|
[dependencies]
|
|
10
20
|
aho-corasick = "1.1"
|
|
11
21
|
chrono = { version = "0.4", features = ["serde"] }
|
|
12
22
|
chrono-tz = "0.10"
|
|
13
23
|
postcard = { version = "1.1", features = ["alloc"] }
|
|
14
|
-
rayon = "1.10"
|
|
24
|
+
rayon = { version = "1.10", optional = true }
|
|
15
25
|
regex = "1.11"
|
|
16
26
|
rustc-hash = "2.1"
|
|
17
27
|
serde = { version = "1.0", features = ["derive"] }
|
|
@@ -23,3 +33,7 @@ serde_json = "1.0"
|
|
|
23
33
|
|
|
24
34
|
[dev-dependencies]
|
|
25
35
|
criterion = "0.5"
|
|
36
|
+
|
|
37
|
+
[[bench]]
|
|
38
|
+
name = "parse_bench"
|
|
39
|
+
harness = false
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# dateoxide
|
|
2
|
+
|
|
3
|
+
[](https://github.com/Pastalikek65/dateoxide/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/dateoxide/)
|
|
5
|
+
[](https://crates.io/crates/dateoxide-core)
|
|
6
|
+
[](https://docs.rs/dateoxide-core)
|
|
7
|
+
[](https://pypi.org/project/dateoxide/)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
**Blazing-fast, low-memory, multilingual natural-language date parser written in Rust — a full-featured drop-in replacement for Python's [`dateparser`](https://github.com/scrapinghub/dateparser).**
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install dateoxide # Python (pre-built cp39-abi3 wheels: Linux, macOS, Windows)
|
|
14
|
+
cargo add dateoxide-core # Pure Rust crate
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`dateoxide` replaces runtime Python regex compilation and 205 dynamically imported locale modules with a compiled zero-backtracking Rust engine (`dateoxide-core`) exposed to Python via **PyO3 + maturin**.
|
|
18
|
+
|
|
19
|
+
- **108x – 7,210x faster** single-threaded parsing (`977x – 36,034x` with GIL-free parallel `parse_batch`)
|
|
20
|
+
- **7.4x lower memory footprint** (`+6.93 MB` vs `+51.56 MB` RSS delta across 205 languages)
|
|
21
|
+
- **17.3x faster cold import** (`5.21 ms` vs `90.22 ms`) via PEP 562 lazy submodules
|
|
22
|
+
- **Zero ReDoS** — linear-time parsing with zero catastrophic backtracking
|
|
23
|
+
- **3,102+ automated tests passing in <4s** — including 1,010 upstream `scrapinghub/dateparser` test vectors, exact `datetime` assertions across 205 languages, `dateparser` compatibility & fuzzing matrices, known `dateparser` bug regressions, and 3,792 official Saudi Umm al-Qura Hijri dates
|
|
24
|
+
- **Official Saudi Umm al-Qura Hijri Calendar (1343–1500 AH)** embedded directly in pure Rust (3,792/3,792 month-start & month-end dates verified against `hijridate`, with zero runtime dependencies), plus Jalali, Minguo, and French Republican calendars
|
|
25
|
+
- **Complete `dateparser` feature parity**:
|
|
26
|
+
- `parse()`, `DateDataParser` (`get_date_data`, `get_date_tuple`, `parts`, `part_of_day`), `search_dates(..., add_period=..., add_detected_language=...)`
|
|
27
|
+
- `Settings`, `SettingValidationError`, `PartOfDay`, `PartsOfDay`, `apply_settings`, `conf`
|
|
28
|
+
- `FreshnessDateDataParser` (`freshness_date_parser`) & `timezone_parser.pop_tz_offset_from_string`
|
|
29
|
+
- `utils.time_spans` (`detect_time_span`, `generate_time_span`, `RETURN_TIME_SPAN`, `DEFAULT_START_OF_WEEK`, `DEFAULT_DAYS_IN_MONTH`)
|
|
30
|
+
- `IGNORE_SURROUNDING_TEXT`, `STRICT_DATE_ORDER`, `NORMALIZE`, `PARSERS`, `SKIP_TOKENS`, `RETURN_TIME_AS_PERIOD`, `TIMEZONE_ABBREVIATIONS`, `region`, and `detect_languages_function`
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Benchmarks
|
|
35
|
+
|
|
36
|
+
Measured with [`benchmarks/bench_vs_dateparser.py`](benchmarks/bench_vs_dateparser.py) on Python 3.12.10, `dateparser 1.5.1`, Rust 1.99.1 (`--release` with thin LTO).
|
|
37
|
+
|
|
38
|
+
### Cold Import & Memory Footprint (Isolated Subprocesses)
|
|
39
|
+
|
|
40
|
+
| Metric | `dateparser` (Python) | `dateoxide` (Rust) | Improvement |
|
|
41
|
+
| :--- | ---: | ---: | ---: |
|
|
42
|
+
| **Cold import time** | 90.22 ms | **5.21 ms** | **17.3x faster** |
|
|
43
|
+
| **RSS after import** | +8.06 MB | **+0.76 MB** | **10.6x smaller** |
|
|
44
|
+
| **RSS delta after parsing** | +51.56 MB | **+6.93 MB** | **7.4x less RAM** |
|
|
45
|
+
|
|
46
|
+
### Parsing Throughput (Operations / Second)
|
|
47
|
+
|
|
48
|
+
| Workload | `dateparser.parse` | `dateoxide.parse` | `dateoxide.DateDataParser` | `dateoxide.parse_batch` *(Rayon)* |
|
|
49
|
+
| :--- | ---: | ---: | ---: | ---: |
|
|
50
|
+
| **ISO / RFC / Numeric** | 440 /s | **672,789 /s** *(1,531x)* | **3,168,819 /s** *(7,210x)* | **5,364,615 /s** *(12,206x)* |
|
|
51
|
+
| **Multilingual Natural Language (Auto)** | 1,239 /s | **133,916 /s** *(108x)* | **160,849 /s** *(130x)* | **1,211,446 /s** *(977x)* |
|
|
52
|
+
| **Invalid / Non-Date Text (Worst Case)** | 60 /s | **196,333 /s** *(3,279x)* | **262,130 /s** *(4,378x)* | **2,157,386 /s** *(36,034x)* |
|
|
53
|
+
|
|
54
|
+
Reproduce locally (or run the accuracy-checked torture suite):
|
|
55
|
+
```bash
|
|
56
|
+
python benchmarks/bench_vs_dateparser.py
|
|
57
|
+
python benchmarks/torture_benchmark.py --json
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Independent Torture Benchmark (Accuracy, ReDoS & Known Differences)
|
|
61
|
+
|
|
62
|
+
Measured with [`benchmarks/torture_benchmark.py`](benchmarks/torture_benchmark.py) across 79 adversarial cases (multilingual casing/scripts, fractional/conversational phrases, month-end clamping, leap/ISO-week traps, RFC/CLF/DST, false-positive traps), dirty `search_dates`, and 6 ReDoS stress bombs (`dateoxide 0.2.0` vs `dateparser 1.5.1` on Python 3.12.10):
|
|
63
|
+
|
|
64
|
+
| Metric | `dateparser 1.5.1` | `dateoxide 0.2.0` |
|
|
65
|
+
| :--- | ---: | ---: |
|
|
66
|
+
| **Torture accuracy (79 hard cases)** | 66 / 79 (`4,243.30 ms`) | **78 / 79 (`1.60 ms`)** |
|
|
67
|
+
| **Dirty `search_dates` (6 docs)** | 4 / 6 (`1,885.91 ms`) | **6 / 6 (`0.48 ms`)** |
|
|
68
|
+
| **6 ReDoS stress bombs (3k–5k chars)** | `20,111.62 ms` | **`5.46 ms`** |
|
|
69
|
+
| **Full 79-case isolated throughput & RSS** | `57.4 /s` (`+64.52 MB`) | **`20,629.9 /s` (`+10.24 MB`)** *(359.4x)* |
|
|
70
|
+
|
|
71
|
+
**Transparently noted difference (`1 / 79`):**
|
|
72
|
+
- `"2026-13-01"` swaps to `2026-01-13` under default `STRICT_DATE_ORDER="none"` in **both** `dateoxide` and `dateparser` (set `STRICT_DATE_ORDER="all"` to reject invalid month indices strictly).
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Upstream `dateparser` Bugs Fixed / Avoided
|
|
77
|
+
|
|
78
|
+
Tested directly in [`tests/test_dateparser_bugs.py`](tests/test_dateparser_bugs.py):
|
|
79
|
+
|
|
80
|
+
- **Compact ISO-8601 basic (`20261126T153000Z`):** `dateparser 1.5.1` misparses this as year `1608-01-02`; `dateoxide` returns `2026-11-26 15:30:00+00:00`.
|
|
81
|
+
- **Quadratic ReDoS & punctuation runs (`GHSA-rx9v-94ff-9cc2`, `#426`):** `5,000` repeated dots/dashes/Arabic commas return `None` in microseconds.
|
|
82
|
+
- **Long-running memory & latency stability (`#457`, `#1140`):** Stateless Rust core with zero unbounded `previous_locales` growth.
|
|
83
|
+
- **Timestamp fragmentation in `search_dates` (`#968`):** `"Server rebooted at 2026-11-26 15:30:00 UTC successfully."` stays grouped as a single combined match.
|
|
84
|
+
- **Extreme overflow protection:** Inputs like `"+999999999999999 days ago"` or `"5000 years ago"` cleanly return `None` instead of overflowing or raising out-of-range errors.
|
|
85
|
+
- **Turkish `İ`/`I`/`ı` casing & leap/month-end clamping:** `"15 OCAK 2026"`, `"3 GÜN ÖNCE"`, `"DÜN SAAT 14:30"` work out of the box without false-positive city names like `"İSTANBUL"`.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Quick Start (Python)
|
|
90
|
+
|
|
91
|
+
### Drop-in replacement for `dateparser`
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
import dateoxide as dateparser
|
|
95
|
+
|
|
96
|
+
dateparser.parse("3 days ago")
|
|
97
|
+
dateparser.parse("2 days") # bare relative durations
|
|
98
|
+
dateparser.parse("3 gün önce")
|
|
99
|
+
dateparser.parse("3 gun once") # diacritic-folded normalization
|
|
100
|
+
dateparser.parse("dün gece") # time-of-day phrases
|
|
101
|
+
dateparser.parse("yesterday at noon")
|
|
102
|
+
dateparser.parse("vor 2 Wochen")
|
|
103
|
+
dateparser.parse("hier à 14h30")
|
|
104
|
+
dateparser.parse("12 de diciembre de 2025")
|
|
105
|
+
dateparser.parse("2026년 11월 26일") # Korean
|
|
106
|
+
dateparser.parse("2026年11月26日") # Japanese / Chinese
|
|
107
|
+
dateparser.parse("١٢ ديسمبر ٢٠٢٥") # Arabic-Indic numerals
|
|
108
|
+
dateparser.parse("20261126T153000Z") # Compact ISO-8601
|
|
109
|
+
dateparser.parse("Published: 12 December 2025", settings={"IGNORE_SURROUNDING_TEXT": True})
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### `Settings`, `PartsOfDay`, `DateData.parts`, and `DateData.part_of_day`
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from datetime import time
|
|
116
|
+
from dateoxide import DateDataParser, PartsOfDay, Settings
|
|
117
|
+
|
|
118
|
+
cfg = Settings(
|
|
119
|
+
DATE_ORDER="MDY",
|
|
120
|
+
STRICT_DATE_ORDER="all",
|
|
121
|
+
PARTS_OF_DAY=PartsOfDay(morning=time(8, 30)),
|
|
122
|
+
TIMEZONE_ABBREVIATIONS={"FOO": "+04:30"},
|
|
123
|
+
)
|
|
124
|
+
parser = DateDataParser(settings=cfg)
|
|
125
|
+
dd = parser.get_date_data("yesterday morning")
|
|
126
|
+
print(dd.date_obj, dd.parts, dd.part_of_day)
|
|
127
|
+
# 2026-11-25 08:30:00 ('year', 'month', 'day', 'time') PartOfDay.MORNING
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Non-Gregorian Calendars (Zero-Dependency Native Rust)
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from dateoxide.calendars import (
|
|
134
|
+
JalaliCalendar,
|
|
135
|
+
HijriCalendar,
|
|
136
|
+
MinguoCalendar,
|
|
137
|
+
FrenchRepublicanCalendar,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
JalaliCalendar("۵ آذر ۱۴۰۴").get_date() # 2025-11-26
|
|
141
|
+
HijriCalendar("1 Ramadan 1446").get_date() # 2025-03-01 (Official Umm al-Qura)
|
|
142
|
+
MinguoCalendar("115年11月26日").get_date() # 2026-11-26
|
|
143
|
+
FrenchRepublicanCalendar("14 Germinal an III").get_date() # 1795-04-03
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Time Spans, Freshness Parser & `search_dates`
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
from dateoxide.freshness_date_parser import freshness_date_parser
|
|
150
|
+
from dateoxide.search import search_dates
|
|
151
|
+
from dateoxide.utils import time_spans
|
|
152
|
+
|
|
153
|
+
freshness_date_parser.parse("3 gün önce")
|
|
154
|
+
span = time_spans.detect_time_span("Show errors from past 3 days")
|
|
155
|
+
start, end = time_spans.generate_time_span(span)
|
|
156
|
+
|
|
157
|
+
matches = search_dates(
|
|
158
|
+
"Event in December 2025; follow-up 12 Jan 2026",
|
|
159
|
+
add_period=True,
|
|
160
|
+
add_detected_language=True,
|
|
161
|
+
)
|
|
162
|
+
# [('December 2025', datetime(2025, 12, ...), 'month', 'en'), ('12 Jan 2026', datetime(2026, 1, 12, 0, 0), 'day', 'en')]
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Parallel Batch Parsing (GIL-free, Multi-Core)
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
import dateoxide
|
|
169
|
+
|
|
170
|
+
dates = ["2026-11-26", "3 gün önce", "vor 2 Wochen", "not a date"] * 25_000
|
|
171
|
+
results = dateoxide.parse_batch(dates) # Runs across all CPU cores via Rayon
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Real-World Examples (`examples/`)
|
|
175
|
+
|
|
176
|
+
- [`examples/telegram_reminder_bot.py`](examples/telegram_reminder_bot.py) — Multilingual Telegram reminder parser & UTC scheduler
|
|
177
|
+
- [`examples/log_pipeline.py`](examples/log_pipeline.py) — Mixed Nginx CLF / RFC 3339 / bracketed log normalizer with `parse_batch`
|
|
178
|
+
- [`examples/big_data_parser.py`](examples/big_data_parser.py) — 50,000-record multilingual ETL throughput & RSS demo
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
python examples/telegram_reminder_bot.py
|
|
182
|
+
python examples/log_pipeline.py
|
|
183
|
+
python examples/big_data_parser.py
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Standalone Rust Usage (`dateoxide-core`)
|
|
189
|
+
|
|
190
|
+
`dateoxide-core` has zero Python dependencies and can be used directly in Rust applications:
|
|
191
|
+
|
|
192
|
+
```rust
|
|
193
|
+
use dateoxide_core::{calendars, parse, parse_batch, search_dates, settings::Settings};
|
|
194
|
+
|
|
195
|
+
let dt = parse("3 gün önce").unwrap();
|
|
196
|
+
let found = search_dates("Meeting on 12 December 2025", &Settings::default());
|
|
197
|
+
let batch = parse_batch(&["2026-11-26", "vor 2 Wochen", "3日前"], &Settings::default());
|
|
198
|
+
let jalali = calendars::parse_jalali("۵ آذر ۱۴۰۴", &Settings::default());
|
|
199
|
+
let hijri = calendars::parse_hijri("1446/09/01", &Settings::default());
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Architecture: Why Is It So Fast & Lean?
|
|
205
|
+
|
|
206
|
+
1. **Zero-Regex Byte Scanner Fast Path (`fast_path.rs`):** Extended & compact ISO-8601, RFC-2822/3339, delimited numeric dates, standalone compact times (`5:30p.m.`, `09h15`), and Unix timestamps are parsed directly from bytes without touching regexes or locale tables.
|
|
207
|
+
2. **Compile-Time Binary Locale Database (`build.rs` + `postcard`):** All 205 languages (including script-tagged locales like `az-Cyrl`, `sr-Latn`, `uz-Cyrl`) are compiled at build time into a compact embedded binary (`include_bytes!`) lazily loaded via `OnceLock` on first natural-language parse — eliminating Python's 205-module import tax.
|
|
208
|
+
3. **Zero-Regex Structured Relative Patterns (`relative.rs`):** 99.97% of `dateparser`'s 3,621 `relative-type-regex` entries are pure `<prefix><NUMBER><suffix>` shapes. `dateoxide` pre-compiles them into flat prefix/suffix matchers with guaranteed linear time and zero ReDoS risk, plus multi-sense relative disambiguation (`PREFER_DATES_FROM`), bare durations, and configurable `PartsOfDay`.
|
|
209
|
+
4. **O(tokens) Inverted Language Index + Diacritic Folding (`locale/mod.rs`):** Instead of iterating through 205 languages on unknown input, `dateoxide` scores exact and diacritic-folded tokens in `FxHashMap` lookups (plus Unicode script detection for Korean, Japanese, Chinese, Cyrillic, Arabic, Greek, Hebrew, Thai, Devanagari), rejecting non-date strings in microseconds.
|
|
210
|
+
5. **Native Rust Calendars & Time Spans (`calendars.rs`, `umm_al_qura.rs`, `time_spans.rs`):** Official Saudi Umm al-Qura Hijri lookup table (1343–1500 AH), Solar Hijri (Jalali), Minguo, and French Republican calendar arithmetic plus compiled linear-time span detection.
|
|
211
|
+
6. **GIL-Free Rayon Parallelism (`parse_batch`):** Releases Python's GIL via `py.allow_threads` and fans out across all CPU cores with Rayon.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Development & Publishing
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# Build & install release Python extension locally
|
|
219
|
+
maturin develop --release
|
|
220
|
+
|
|
221
|
+
# Run Rust core tests
|
|
222
|
+
cargo test -p dateoxide-core --release
|
|
223
|
+
|
|
224
|
+
# Run full 3,000+ test suite (including parity matrix, fuzzing & Umm al-Qura Hijri)
|
|
225
|
+
pytest -v
|
|
226
|
+
|
|
227
|
+
# Run standard & torture head-to-head benchmarks vs dateparser
|
|
228
|
+
python benchmarks/bench_vs_dateparser.py
|
|
229
|
+
python benchmarks/torture_benchmark.py
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Automated PyPI (OIDC Trusted Publishing) and crates.io multi-platform wheel builds trigger on release tags:
|
|
233
|
+
```bash
|
|
234
|
+
git tag v0.1.0 && git push --tags
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## License & Attribution
|
|
240
|
+
|
|
241
|
+
Dual-licensed under **MIT** or **Apache-2.0**.
|
|
242
|
+
|
|
243
|
+
Multilingual calendar and relative-date lexical data is derived from Unicode CLDR and [`scrapinghub/dateparser`](https://github.com/scrapinghub/dateparser) (BSD 3-Clause License). Official Saudi Umm al-Qura month-start data (1343–1500 AH) is derived from [`dralshehri/hijridate`](https://github.com/dralshehri/hijridate) (MIT License). See [`LICENSE`](LICENSE) and [`NOTICE`](NOTICE) for full details.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
|
2
|
+
use dateoxide_core::{parse_batch, parse_with_settings, search::search_dates, settings::Settings};
|
|
3
|
+
|
|
4
|
+
fn bench_dateoxide_core(c: &mut Criterion) {
|
|
5
|
+
let settings = Settings::default();
|
|
6
|
+
let dashes = "-".repeat(5000);
|
|
7
|
+
let batch_inputs: Vec<&str> = [
|
|
8
|
+
"2026-11-26T15:30:00Z",
|
|
9
|
+
"12 December 2025",
|
|
10
|
+
"3 gün önce",
|
|
11
|
+
"vor 2 Wochen",
|
|
12
|
+
"2026-W48-4",
|
|
13
|
+
"not a date",
|
|
14
|
+
]
|
|
15
|
+
.into_iter()
|
|
16
|
+
.cycle()
|
|
17
|
+
.take(1000)
|
|
18
|
+
.collect();
|
|
19
|
+
|
|
20
|
+
c.bench_function("parse_iso_fast_path", |b| {
|
|
21
|
+
b.iter(|| parse_with_settings(black_box("2026-11-26T15:30:00Z"), &settings))
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
c.bench_function("parse_multilingual_relative", |b| {
|
|
25
|
+
b.iter(|| parse_with_settings(black_box("3 gün önce"), &settings))
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
c.bench_function("parse_multilingual_absolute", |b| {
|
|
29
|
+
b.iter(|| parse_with_settings(black_box("12 December 2025"), &settings))
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
c.bench_function("search_dates_mixed_sentence", |b| {
|
|
33
|
+
b.iter(|| {
|
|
34
|
+
search_dates(
|
|
35
|
+
black_box("Berlin: 12. Dezember 2025, Paris: hier à 14h30"),
|
|
36
|
+
&settings,
|
|
37
|
+
)
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
c.bench_function("redos_dashes_5000", |b| {
|
|
42
|
+
b.iter(|| parse_with_settings(black_box(&dashes), &settings))
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
c.bench_function("parse_batch_1000", |b| {
|
|
46
|
+
b.iter(|| parse_batch(black_box(&batch_inputs), &settings))
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
criterion_group!(benches, bench_dateoxide_core);
|
|
51
|
+
criterion_main!(benches);
|