Skip to content

Commit

Permalink
feat(time): make duration human readable for templating
Browse files Browse the repository at this point in the history
Signed-off-by: simonsan <[email protected]>
  • Loading branch information
simonsan committed Mar 23, 2024
1 parent f3d7597 commit e7e8b4a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/time/src/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub struct PaceDuration(u64);

impl Display for PaceDuration {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", format_duration(Duration::from_secs(self.0)))
write!(f, "{}", self.human_readable())
}
}

Expand All @@ -94,6 +94,11 @@ impl PaceDuration {
self.0
}

#[must_use]
pub fn human_readable(&self) -> String {
format_duration(Duration::from_secs(self.0)).to_string()
}

#[must_use]
pub const fn new(duration: u64) -> Self {
Self(duration)
Expand Down

0 comments on commit e7e8b4a

Please sign in to comment.