Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace compound_duration with humantime #26

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ progress-tree-log = ["log"]
progress-log = ["log"]
unit-bytes = ["bytesize"]
unit-human = ["human_format"]
unit-duration = ["compound_duration"]
unit-duration = ["humantime"]
render-tui-termion = ["crosstermion/tui-react-termion"]
render-tui-crossterm = ["crosstermion/tui-react-crossterm", "crosstermion/input-async-crossterm"]
render-tui = ["tui",
Expand Down Expand Up @@ -76,7 +76,7 @@ tui = { package = "ratatui", version = "0.20.1", optional = true, default-featur
tui-react = { version = "0.20.0", optional = true }
futures-core = { version = "0.3.4", optional = true, default-features = false }
futures-lite = { version = "1.5.0", optional = true }
humantime = { version = "2.0.0", optional = true }
humantime = { version = "2.1.0", optional = true }
unicode-segmentation = { version = "1.6.0", optional = true }
unicode-width = { version = "0.1.7", optional = true }
crosstermion = { version = "0.11.0", optional = true, default-features = false }
Expand All @@ -93,7 +93,6 @@ is-terminal = { version = "0.4.9", optional = true }
# units
bytesize = { version = "1.0.1", optional = true }
human_format = { version = "1.0.3", optional = true }
compound_duration = { version = "1.2.0", optional = true }

[package.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ This crate comes with various cargo features to tailor it to your needs.
* **unit-human**
* Display counts in a way that is easier to grasp for humans, using the tiny `human_format` crate.
* **unit-duration**
* Displays time in seconds like '_5m4s_' using the tiny `compound_duration` crate.
* Displays time in seconds like '_5m4s_' using the tiny `humantime` crate.

## Features

Expand Down
8 changes: 5 additions & 3 deletions src/unit/duration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use std::fmt;
use std::{fmt, time::Duration as StdDuration};

use humantime::format_duration;

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

Expand All @@ -8,13 +10,13 @@ pub struct Duration;

impl DisplayValue for Duration {
fn display_current_value(&self, w: &mut dyn fmt::Write, value: Step, _upper: Option<Step>) -> fmt::Result {
w.write_str(&compound_duration::format_dhms(value))
w.write_str(&format_duration(StdDuration::new(value as u64, 0)).to_string())
}
fn separator(&self, w: &mut dyn fmt::Write, _value: Step, _upper: Option<Step>) -> fmt::Result {
w.write_str(" of ")
}
fn display_upper_bound(&self, w: &mut dyn fmt::Write, upper_bound: Step, _value: Step) -> fmt::Result {
w.write_str(&compound_duration::format_dhms(upper_bound))
w.write_str(&format_duration(StdDuration::new(upper_bound as u64, 0)).to_string())
}

fn dyn_hash(&self, state: &mut dyn std::hash::Hasher) {
Expand Down
Loading