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() -> Result<(), Box<dyn std::error::Error>> {
    let date = Date::new(2023, 6, 15);
    let time = Time::new(14, 30, 45);
    let datetime = DateTime::new(date, time, 0);

    println!("Date: {}", date);
    println!("Time: {}", time);
    println!("DateTime: {}", datetime);

    let parsed_date: Date = "2023-06-15".parse()?;
    let parsed_time: Time = "14:30:45.123456".parse()?;
    let parsed_datetime: DateTime = "2023-06-15T14:30:45Z".parse()?;

    println!("Parsed Date: {}", parsed_date);
    println!("Parsed Time: {}", parsed_time);
    println!("Parsed DateTime: {}", parsed_datetime);

    let future_date = date.add_days(30);
    let past_date = date.sub_days(15);
    let future_month = date.add_months(2);

    println!("30 days later: {}", future_date);
    println!("15 days ago: {}", past_date);
    println!("2 months later: {}", future_month);

    let future_time = time + Time::new(1, 30, 0);
    println!("1.5 hours later: {}", future_time);

    let future_datetime = datetime.add_seconds(3600);
    println!("1 hour later: {}", future_datetime);

    println!("Is weekend: {}", date.is_weekend());
    println!("Is leap year: {}", date.leap_year());
    println!("Day of year: {}", date.year_day());
    println!("Quarter: {}", date.quarter());

    println!("Days since Unix epoch: {}", date.to_days());
    println!(
        "Seconds since Unix epoch: {}",
        datetime.to_seconds_from_unix_epoch()
    );
    println!("ISO 8601 format: {}", datetime.to_iso_8061());

    println!("\n=== Custom Formatting ===");
    println!("Date: {}", date.format("%A, %B %d, %Y")?);
    println!("Time: {}", time.format("%I:%M %p")?);
    println!("DateTime: {}", datetime.format("%Y-%m-%d %H:%M:%S")?);

    let now = DateTime::now();
    println!("Current time: {}", now.format("%Y-%m-%d %H:%M:%S")?);
    println!("Current time (12-hour): {}", now.format("%I:%M:%S %p")?);

    Ok(())
}