iso8601-duration
Parse ISO8601 duration format.
https://en.wikipedia.org/wiki/ISO_8601#Durations
Installation
= "0.2.0"
Usage
use Duration;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert!;
assert!;
assert!;
assert!;
year
and month
Duration
can be converted to either std::time::Duration
or
chrono::Duration
by calling to_std
or to_chrono
.
Both to_std
and to_chrono
will return None
if the duration
includes year
and month
. Because ISO8601 duration format allows
the usage of year
and month
, and these durations are non-standard.
Since months can have 28, 29 30, 31 days, and years can have either
365 or 366 days.
To perform a lossless conversion, a starting date must be specified:
// requires `chrono` feature
use Duration;
use DateTime;
let one_month: Duration = "P1M".parse.unwrap;
let date = parse_from_rfc3339.unwrap;
assert_eq!;
License: MIT