1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Parse ISO8601 duration format.
//!
//! # Installation
//!
//! ```toml
//! iso8601-duration = "0.1.0"
//! ```
//!
//! # Usage
//!
//! ```rust
//! use iso8601_duration::Duration;
//! use nom::{error::ErrorKind, Err};
//!
//!  assert_eq!(
//!      Duration::parse("P23DT23H"),
//!      Ok(Duration::new(0., 0., 23., 23., 0., 0.))
//!  );
//!  assert_eq!(
//!      Duration::parse("P3Y6M4DT12H30M5S"),
//!      Ok(Duration::new(3., 6., 4., 12., 30., 5.))
//!  );
//!  assert_eq!(
//!      Duration::parse("P0.5Y"),
//!      Ok(Duration::new(0.5, 0., 0., 0., 0., 0.))
//!  );
//!  assert_eq!(
//!      Duration::parse("P0.5Y0.5M"),
//!      Ok(Duration::new(0.5, 0.5, 0., 0., 0., 0.))
//!  );
//!  assert_eq!(
//!      Duration::parse("P12W"),
//!      Ok(Duration::new(0., 0., 84., 0., 0., 0.))
//!  );
//!
//!  assert_eq!(
//!      Duration::parse("PT"),
//!      Err(Err::Error(("", ErrorKind::Verify)))
//!  );
//!  assert_eq!(
//!      Duration::parse("P12WT12H30M5S"),
//!      Err(Err::Error(("T12H30M5S", ErrorKind::Eof)))
//!  );
//!  assert_eq!(
//!      Duration::parse("P0.5S0.5M"),
//!      Err(Err::Error(("0.5S0.5M", ErrorKind::Verify)))
//!  );
//!  assert_eq!(
//!      Duration::parse("P0.5A"),
//!      Err(Err::Error(("0.5A", ErrorKind::Verify)))
//!  );
//! ```

mod duration;

pub use crate::duration::Duration;