Skip to content

Commit

Permalink
refactor duration formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ultram4rine committed May 1, 2022
1 parent 8b82e43 commit 810c21b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn format_duration(duration: Duration) -> String {
};

format!(
"{}{}{}{}{}{}",
"{} {} {} {} {} {}",
f_weeks, f_days, f_hours, f_minutes, f_seconds, f_milliseconds
)
.trim()
Expand All @@ -60,8 +60,8 @@ pub fn format_duration(duration: Duration) -> String {
fn format_unit(unit: String, units: String, count: i64) -> String {
match count {
0 => "".to_owned(),
1 => format!(" 1 {}", unit),
_ => format!(" {} {}", count, units),
1 => format!("1 {}", unit),
_ => format!("{} {}", count, units),
}
}

Expand Down

0 comments on commit 810c21b

Please sign in to comment.