Skip to content

Commit

Permalink
Always indent millis
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-braun committed Oct 20, 2023
1 parent e56756d commit 54289db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ use regex::Regex;
use serde::de::Visitor;
use serde::Deserialize;
use serde::Serialize;
use thiserror::Error;

/// A point in time.
///
Expand Down Expand Up @@ -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(())
}
Expand Down Expand Up @@ -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!(
Expand Down

0 comments on commit 54289db

Please sign in to comment.