rstime 0.1.0

A zero-dependency Rust time library providing date, time, datetime types with formatting, parsing, Unix timestamps, and clock functionality.
Documentation
use rstime::{DateTime, Date, Time, Duration, TimeDelta, TimeFormat, MonotonicClock};

fn main() {
    println!("=== rstime 时间库使用示例 ===\n");

    println!("1. 获取当前时间");
    let now = DateTime::now();
    println!("   现在: {}\n", now);

    println!("2. 格式化输出");
    let dt = DateTime::from_ymd_hms_milli(2026, 5, 10, 14, 5, 9, 37);
    println!("   ISO 8601:  {}", dt.format("{YYYY}-{MM}-{DD}T{HH}:{mm}:{ss}"));
    println!("   中文格式:  {}", dt.format("{YYYY}年{MM}月{DD}日 {HH}:{mm}:{ss}"));
    println!("   12小时制:  {}", dt.format("{hh}:{mm}:{ss} {AMPM}"));
    println!("   星期:      {}", dt.format("{WW}"));
    println!("   毫秒:      {}", dt.format("{SSS}"));
    println!();

    println!("3. 日期计算");
    let d1 = Date::new(2026, 1, 1);
    let d2 = d1 + TimeDelta::new(365 * 86400, 0);
    let diff = d2 - d1;
    println!("   {} + 365 天 = {}", d1, d2);
    println!("   相差 {}", diff.total_seconds() as i64 / 86400);
    println!();

    println!("4. 星期计算");
    let dates = [Date::new(2026, 1, 1), Date::new(2026, 5, 10), Date::new(2026, 12, 25)];
    for d in &dates {
        println!("   {} = {}", d, d.weekday());
    }
    println!();

    println!("5. 闰年判断");
    for year in [2024, 2025, 2000, 1900] {
        println!("   {}: {}", year, if Date::new(year, 1, 1).is_leap_year() { "闰年" } else { "平年" });
    }
    println!();

    println!("6. Unix 时间戳");
    let epoch = DateTime::from_unix(0);
    println!("   epoch:     {}", epoch);
    let ts = now.unix_timestamp();
    println!("   当前时间戳: {}", ts);
    let ts_ms = now.unix_timestamp_millis();
    println!("   毫秒时间戳: {}", ts_ms);
    println!();

    println!("7. 时间加法(跨天回绕)");
    let t = Time::from_hms(23, 30, 0);
    println!("   {} + 2h = {}", t, t + Duration::from_secs(7200));
    println!("   {} - 1h = {}", t, t - Duration::HOUR);
    println!();

    println!("8. 时钟功能");
    let today = Date::today();
    let time_now = Time::now();
    println!("   今天: {}", today);
    println!("   此刻: {}", time_now);
    println!();

    println!("9. 单调时钟(性能计时)");
    let timer = MonotonicClock::start();
    let _sum: u64 = (0..10_000_000).sum();
    let elapsed = timer.elapsed();
    println!("   累加 1000 万次耗时: {}ms", elapsed.total_millis());
    println!();

    println!("✅ 所有示例运行完成!");
}