simple-datetime-rs 0.3.0

A high-performance, lightweight date and time library for Rust with dramatically faster parsing, memory-efficient operations, and chrono-compatible formatting
Documentation
use simple_datetime_rs::{Date, DateTime, Format, Time};

fn main() {
    println!("=== Millisecond Formatting Demo ===");

    // Create a DateTime with microseconds
    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()
    );

    // Test with different millisecond values
    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());

    // Test with zero milliseconds
    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());

    // Test with Time only
    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()
    );
}