Skip to main content

Crate dtrexp

Crate dtrexp 

Source
Expand description

DTRExp — Date-Time Range & Recurrence Expression (draft 2.8).

A compact string expression denoting a possibly-infinite set of time intervals, evaluated for coverage (“is this instant inside the set?”).

use dtrexp::{parse, Tz};

let expr = parse("T0900:1800 E1:5").unwrap();      // business hours
assert!(expr.warnings().is_empty());
// 2026-07-07 (a Tuesday) 10:00:00Z, in ms since the Unix epoch:
let t = 1_783_591_200_000;
assert!(expr.covers(t, "UTC").unwrap());
// or with a preloaded zone (infallible):
assert!(expr.covers_in(t, &Tz::utc()));

Instants are milliseconds since the Unix epoch (UTC). The evaluation time zone is a parameter; the default is Tz::utc.

Structs§

Dtrexp
A parsed, validated DTRExp.
ParseError
A parse/validation failure, positioned at a byte offset into the input.
Tz
A parsed time zone: a sorted list of UTC transition instants, each paired with the offset (seconds east of UTC) that takes effect at that instant.
UnknownTimeZone
The one runtime failure: an IANA time-zone identifier that does not resolve to a usable zone — unknown, invalid, or an unreadable TZif entry. Parse errors aside, nothing else in the crate fails.
Warning
A non-fatal diagnostic: the expression parsed, but is (e.g.) statically unsatisfiable. Carries the byte offset of the offending component.

Functions§

parse
Parse and statically validate a DTRExp string.
validate
Parse and return only the warnings (errors are still returned as Err).