#![no_std]
extern crate alloc;
pub use pretty::splitter::Millisecond;
pub use pretty::{MillisecondFormatter, MillisecondOption};
pub use relative::parser::RelativePart;
pub mod prelude;
pub mod pretty;
pub mod relative;
pub mod weekday;
#[cfg(test)]
mod tests {
#[test]
fn should_work_always_with_backward_compatiblity() {
use crate::prelude::*;
let dur = core::time::Duration::from_millis(33_023_448_000);
assert_eq!("1y 17d 5h 10m 48s", dur.pretty());
assert_eq!(
"1 year 17 days 5 hours 10 minutes 48 seconds",
dur.pretty_with(MillisecondOption::long())
);
assert_eq!("about a year ago", dur.relative());
let ms = Millisecond::from_millis(33_023_448_000);
assert_eq!("1y 17d 5h 10m 48s", ms.pretty());
let combine = core::time::Duration::from_millis(448_123).pretty_with(MillisecondOption {
seconds: SecondsOptions::CombineWith {
precision: Some(2),
fixed_width: false,
},
..Default::default()
});
assert_eq!("7m 28.12s", combine);
}
}