diff --git a/Cargo.toml b/Cargo.toml index 4d28f1e..f60be9c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ derive_more = "0.99.17" lazy_static = "1.4.0" regex = "1.7.1" serde = { version = "1.0.152", features = ["derive"], default-features = false } +thiserror = "1.0.50" [dev-dependencies] serde_test = "1.0.152" diff --git a/src/lib.rs b/src/lib.rs index 8a4ec17..848f62f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -68,6 +68,7 @@ use regex::Regex; use serde::de::Visitor; use serde::Deserialize; use serde::Serialize; +use thiserror::Error; /// A point in time. /// @@ -339,7 +340,7 @@ impl Debug for Time { write!(f, "{:02}:", minutes_part)?; write!(f, "{:02}", seconds_part)?; if millis_part > 0 { - write!(f, ".{}", millis_part)?; + write!(f, ".{:03}", millis_part)?; } Ok(()) } @@ -1434,6 +1435,11 @@ mod time_test { input: Time::millis(i64::MIN), expected: "-2562047788015:12:55.808".to_string(), }, + TestCase { + name: "millis", + input: Time::hours(3) + Duration::millis(42), + expected: "03:00:00.042".to_string(), + }, ]; for test in tests { assert_eq!(