use simple_datetime_rs::{Date, DateTime, Format, Time};
fn main() {
println!("=== Millisecond Formatting Demo ===");
let time = Time::new_with_microseconds(14, 30, 45, 123456);
let dt = DateTime::new(Date::new(2023, 6, 15), time, 0);
println!(
"Original format (microseconds): {}",
dt.format("%Y-%m-%d %H:%M:%S.%f").unwrap()
);
println!(
"New format (milliseconds): {}",
dt.format("%Y-%m-%d %H:%M:%S.%.3f").unwrap()
);
let time2 = Time::new_with_microseconds(9, 15, 30, 50000);
let dt2 = DateTime::new(Date::new(2023, 6, 15), time2, 0);
println!("50ms: {}", dt2.format("%Y-%m-%d %H:%M:%S.%.3f").unwrap());
let time3 = Time::new_with_microseconds(23, 59, 59, 999000);
let dt3 = DateTime::new(Date::new(2023, 6, 15), time3, 0);
println!("999ms: {}", dt3.format("%Y-%m-%d %H:%M:%S.%.3f").unwrap());
let time4 = Time::new_with_microseconds(12, 0, 0, 0);
let dt4 = DateTime::new(Date::new(2023, 6, 15), time4, 0);
println!("0ms: {}", dt4.format("%Y-%m-%d %H:%M:%S.%.3f").unwrap());
println!("\n=== Time-only formatting ===");
println!(
"Time with microseconds: {}",
time.format("%H:%M:%S.%f").unwrap()
);
println!(
"Time with milliseconds: {}",
time.format("%H:%M:%S.%.3f").unwrap()
);
}