You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I realized that if the number of miliseconds is not an exact multiple of seconds, minutes, ..., then it will end generating an string with the default ms. For example, the following test would fail:
#[test]fntest_display_trait_2(){let d = DurationString::try_from(Duration::from_millis(1100));assert_eq!("1s", format!("{}", d.unwrap()));}
The fix for that would pass through replacing these lines:
if ms % DAY_IN_MILLI == 0{return(ms / DAY_IN_MILLI).to_string() + "d";}
by
if ms >= DAY_IN_MILLI{return(ms / DAY_IN_MILLI).to_string() + "d";}
The text was updated successfully, but these errors were encountered:
It would be nice to somehow be able to say what the smallest unit should be like, minutes or seconds and having it automatically round to the nearest or even more config that allows the consumer to decide if its round up, down or discard lesser units.
RonniSkansing
changed the title
String representation always in ms
[Feature Request] String representation always in ms
May 8, 2023
Hi, I realized that if the number of miliseconds is not an exact multiple of seconds, minutes, ..., then it will end generating an string with the default
ms
. For example, the following test would fail:The fix for that would pass through replacing these lines:
by
The text was updated successfully, but these errors were encountered: