Skip to content

Commit f5143c9

Browse files
replace compound_duration with humantime
This is the humantime part of PR #25
1 parent bb1eadf commit f5143c9

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ progress-tree-log = ["log"]
4444
progress-log = ["log"]
4545
unit-bytes = ["bytesize"]
4646
unit-human = ["human_format"]
47-
unit-duration = ["compound_duration"]
47+
unit-duration = ["humantime"]
4848
render-tui-termion = ["crosstermion/tui-react-termion"]
4949
render-tui-crossterm = ["crosstermion/tui-react-crossterm", "crosstermion/input-async-crossterm"]
5050
render-tui = ["tui",
@@ -76,7 +76,7 @@ tui = { package = "ratatui", version = "0.20.1", optional = true, default-featur
7676
tui-react = { version = "0.20.0", optional = true }
7777
futures-core = { version = "0.3.4", optional = true, default-features = false }
7878
futures-lite = { version = "1.5.0", optional = true }
79-
humantime = { version = "2.0.0", optional = true }
79+
humantime = { version = "2.1.0", optional = true }
8080
unicode-segmentation = { version = "1.6.0", optional = true }
8181
unicode-width = { version = "0.1.7", optional = true }
8282
crosstermion = { version = "0.11.0", optional = true, default-features = false }
@@ -93,7 +93,6 @@ is-terminal = { version = "0.4.9", optional = true }
9393
# units
9494
bytesize = { version = "1.0.1", optional = true }
9595
human_format = { version = "1.0.3", optional = true }
96-
compound_duration = { version = "1.2.0", optional = true }
9796

9897
[package.metadata.docs.rs]
9998
all-features = true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ This crate comes with various cargo features to tailor it to your needs.
7373
* **unit-human**
7474
* Display counts in a way that is easier to grasp for humans, using the tiny `human_format` crate.
7575
* **unit-duration**
76-
* Displays time in seconds like '_5m4s_' using the tiny `compound_duration` crate.
76+
* Displays time in seconds like '_5m4s_' using the tiny `humantime` crate.
7777

7878
## Features
7979

src/unit/duration.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use std::fmt;
1+
use std::{fmt, time::Duration as StdDuration};
2+
3+
use humantime::format_duration;
24

35
use crate::{progress::Step, unit::DisplayValue};
46

@@ -8,13 +10,13 @@ pub struct Duration;
810

911
impl DisplayValue for Duration {
1012
fn display_current_value(&self, w: &mut dyn fmt::Write, value: Step, _upper: Option<Step>) -> fmt::Result {
11-
w.write_str(&compound_duration::format_dhms(value))
13+
w.write_str(&format_duration(StdDuration::new(value as u64, 0)).to_string())
1214
}
1315
fn separator(&self, w: &mut dyn fmt::Write, _value: Step, _upper: Option<Step>) -> fmt::Result {
1416
w.write_str(" of ")
1517
}
1618
fn display_upper_bound(&self, w: &mut dyn fmt::Write, upper_bound: Step, _value: Step) -> fmt::Result {
17-
w.write_str(&compound_duration::format_dhms(upper_bound))
19+
w.write_str(&format_duration(StdDuration::new(upper_bound as u64, 0)).to_string())
1820
}
1921

2022
fn dyn_hash(&self, state: &mut dyn std::hash::Hasher) {

0 commit comments

Comments
 (0)