diff --git a/Cargo.toml b/Cargo.toml index 4d57493f..894b82b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -91,7 +91,7 @@ version = "0.1.5" [dependencies.tracing-subscriber] version = "0.3.20" -features = ["env-filter", "fmt", "json", "local-time", "time"] +features = ["env-filter", "fmt", "json", "local-time"] [dev-dependencies] assert_cmd = "2.1.2" diff --git a/src/band.rs b/src/band.rs index 0e484d17..875c35a7 100644 --- a/src/band.rs +++ b/src/band.rs @@ -347,7 +347,11 @@ mod tests { assert_eq!(info.id.to_string(), "b0000"); assert!(info.is_closed); assert_eq!(info.index_hunk_count, Some(0)); - let dur = info.end_time.expect("info has an end_time") - info.start_time; + let dur = info + .end_time + .expect("info has an end_time") + .since(info.start_time) + .unwrap(); // Test should have taken (much) less than 5s between starting and finishing // the band. (It might fail if you set a breakpoint right there.) assert!(dur.get_seconds() < 5); diff --git a/src/show.rs b/src/show.rs index f0cf10ca..18710b40 100644 --- a/src/show.rs +++ b/src/show.rs @@ -93,11 +93,14 @@ pub async fn show_versions( if options.backup_duration { let duration_str: Cow = if info.is_closed { if let Some(end_time) = info.end_time { - let duration = end_time - info.start_time; - if let Ok(duration) = duration.try_into() { - duration_to_hms(duration).into() - } else { - Cow::Borrowed("negative") + let span = end_time.since(info.start_time).unwrap(); + // Convert jiff::Span to std::time::Duration + match span.total(jiff::Unit::Nanosecond) { + Ok(total_nanos) if total_nanos >= 0.0 => { + let duration = std::time::Duration::from_nanos(total_nanos as u64); + duration_to_hms(duration).into() + } + _ => Cow::Borrowed("negative"), } } else { Cow::Borrowed("unknown")