fixed fmt

This commit is contained in:
objz committed 2026-08-24 19:17:37 +02:00
1 parent e99e307790
commit e1cce7b5b3
5 files changed
+22 -18

No files matched your search

+11 -7
View File
@@ -12,15 +12,19 @@ fn create_log_file_name_has_millisecond_precision() {
// stem is 22 chars: %Y-%m-%d_%H-%M-%S%3f
let stem = name.strip_suffix(".log").unwrap();
assert_eq!(stem.len(), 22, "name={name}");
assert!(stem[stem.len() - 3..].chars().all(|c| c.is_ascii_digit()), "name={name}");
assert!(
stem[stem.len() - 3..].chars().all(|c| c.is_ascii_digit()),
"name={name}"
);
// pin the pattern: %3f must be zero-padded so names stay sortable
let dt = chrono::NaiveDateTime::parse_from_str(
"2025-01-02T15:04:05.005",
"%Y-%m-%dT%H:%M:%S%.3f",
)
.unwrap();
assert_eq!(dt.format("%Y-%m-%d_%H-%M-%S%3f").to_string(), "2025-01-02_15-04-05005");
let dt =
chrono::NaiveDateTime::parse_from_str("2025-01-02T15:04:05.005", "%Y-%m-%dT%H:%M:%S%.3f")
.unwrap();
assert_eq!(
dt.format("%Y-%m-%d_%H-%M-%S%3f").to_string(),
"2025-01-02_15-04-05005"
);
}
#[test]