Expand description
Django-shape ISO 8601 date / time / datetime / duration string
parsers — dateparse::{parse_date, parse_time, parse_datetime, parse_duration}. Mirrors django.utils.dateparse.*.
Django-shape ISO 8601 / W3C datetime parsers.
Mirrors django.utils.dateparse.{parse_date, parse_time, parse_datetime, parse_duration}. Each returns Option<T> —
None on any parse failure, matching Django’s “return None
when the input doesn’t conform” shape.
Designed for inputs that come from JSON APIs, form fields, and URL query strings — where you’ve already validated “this is a string” but need to know if it’s a parseable date/time/duration.
ⓘ
use rustango::dateparse::{parse_date, parse_time, parse_datetime, parse_duration};
assert!(parse_date("2026-06-04").is_some());
assert!(parse_time("12:30:00").is_some());
assert!(parse_datetime("2026-06-04T12:30:00Z").is_some());
assert!(parse_duration("PT1H30M").is_some()); // ISO 8601 duration
assert!(parse_duration("1 day, 2:30:00").is_some()); // Django shapeFunctions§
- duration_
iso_ string django.utils.duration.duration_iso_string(timedelta)— ISO 8601 duration string for astd::time::Duration.- duration_
string - Django-parity
parse_duration(value)— parse a duration string into astd::time::Duration. Accepts two shapes (matching Django’s union): - parse_
date - Django-parity
parse_date(value)— parse an ISO 8601 date (YYYY-MM-DD) into aNaiveDate. ReturnsNoneon any formatting / out-of-range failure. - parse_
datetime - Django-parity
parse_datetime(value)— parse an ISO 8601 datetime (YYYY-MM-DDTHH:MM:SS[.fff][Z|±HH:MM]) into aDateTime<Utc>. BothTand space separator between date and time are accepted (W3C profile / ISO 8601 §4.1.2.5). - parse_
duration - parse_
time - Django-parity
parse_time(value)— parse an ISO 8601 time (HH:MM:SS[.fff]) into aNaiveTime. Optional fractional seconds are accepted; the wire format does NOT include timezone.