use alloc::string::String;
use core::time::Duration;
use crate::MillisecondOption;
pub trait MillisecondFormatter {
type Output;
fn pretty_with(&self, opt: MillisecondOption) -> Self::Output;
fn pretty(&self) -> Self::Output {
self.pretty_with(MillisecondOption::default())
}
#[deprecated(since = "0.4.0", note = "use the `pretty` instead")]
fn to_short_string(&self) -> Self::Output {
self.pretty()
}
#[deprecated(since = "0.4.0", note = "use the `pretty_with` function instead")]
fn to_long_string(&self) -> Self::Output {
self.pretty_with(MillisecondOption::long())
}
}
impl MillisecondFormatter for Duration {
type Output = String;
fn pretty_with(&self, opt: MillisecondOption) -> Self::Output {
let parts = super::parser::parse_duration(self, &opt);
super::parser::ms_parts_to_string(&parts, &opt)
}
}