dateutil
Fast date utility library for Rust — parser, relativedelta, rrule, timezone.
A performance-focused Rust reimplementation of python-dateutil, designed for native Rust usage. Also available as a Python package (python-dateutil-rs) via PyO3.
Features
- Parser — Parse human-readable date strings with a zero-copy tokenizer and PHF lookup tables
- ISO 8601 — Strict ISO-8601 parsing via
isoparse() - RelativeDelta — Relative date arithmetic (months, years, weekdays, etc.)
- RRule / RRuleSet — RFC 5545 recurrence rules with bitflag filters and buffer-reusing iteration
- Timezone —
gettz()with TZif file support, DST handling, and process-lifetime caching - Easter — Easter date calculation (Julian, Orthodox, Western)
- Weekday —
MO–SUconstants with N-th occurrence support
Installation
[]
= "0.1"
Quick Start
Parsing date strings
use NaiveDate;
use parser;
// Parse a human-readable date string
let dt = parse
.unwrap;
assert_eq!;
// ISO-8601 strict parsing
use isoparse;
let dt = isoparse.unwrap;
Relative deltas
use ;
use RelativeDelta;
let dt = from_ymd_opt.unwrap.and_hms_opt.unwrap;
let rd = new.months.build;
// Jan 31 + 1 month = Feb 28 (clamped)
let result = rd.add_to_datetime;
assert_eq!;
Recurrence rules
use NaiveDate;
use ;
let dtstart = from_ymd_opt.unwrap
.and_hms_opt.unwrap;
let rule = new
.dtstart
.count
.build
.unwrap;
let dates = rule.all;
assert_eq!;
// Also works as an iterator
for dt in rule.iter.take
Parsing RFC 5545 RRULE strings
use rrulestr;
let result = rrulestr.unwrap;
Timezones
use NaiveDate;
use ;
// Look up an IANA timezone (cached after first call)
let tz = gettz.unwrap;
let dt = from_ymd_opt.unwrap
.and_hms_opt.unwrap;
// UTC offset in seconds (EDT = -4h)
assert_eq!;
// DST gap/overlap utilities
assert!;
assert!;
Easter
use NaiveDate;
use ;
let date = easter.unwrap;
assert_eq!;
Weekday constants
use ;
// N-th occurrence (e.g., 2nd Tuesday)
let second_tue = TU.nth;
assert_eq!;
Modules
| Module | Description |
|---|---|
dateutil::parser |
Date string parsing (parse, isoparse, parse_to_result) |
dateutil::relativedelta |
Relative date arithmetic (RelativeDelta, RelativeDeltaBuilder) |
dateutil::rrule |
RFC 5545 recurrence rules (RRule, RRuleBuilder, Recurrence) |
dateutil::rrule::set |
Recurrence rule sets (RRuleSet) |
dateutil::rrule::parse |
RRULE string parsing (rrulestr) |
dateutil::tz |
Timezones (gettz, TzOps, TimeZone, TzFile, TzOffset, TzUtc, TzLocal) |
dateutil::easter |
Easter calculation (easter, EasterMethod) |
dateutil::common |
Weekday constants (MO–SU, Weekday) |
dateutil::error |
Error types (ParseError, RRuleError, TzError, etc.) |
Performance
Benchmarked against python-dateutil (via PyO3 bindings):
| Module | Speedup |
|---|---|
| Parser (parse) | 19.5x–36.0x |
| Parser (isoparse) | 13.0x–38.4x |
| RRule | 5.9x–63.7x |
| Timezone | 1.0x–896.7x |
| RelativeDelta | 2.0x–28.1x |
| Easter | 5.0x–7.3x |
Key optimizations: zero-copy tokenizer, PHF compile-time hash tables, bitflag-based filters, SmallVec buffer reuse, FxHashMap timezone cache, TzOps trait for generic zero-clone dispatch.