use chrono::Local;
use std::env;

fn main() {
    let now = Local::now();
    let build_time = now.format("%Y-%m-%d %H:%M:%S").to_string();

    // Get version from Cargo.toml
    let version = env!("CARGO_PKG_VERSION");
    let full_version = format!("{} (build: {})", version, build_time);

    // Set build-time environment variables
    println!("cargo:rustc-env=BUILD_VERSION={}", full_version);
    println!("cargo:rustc-env=BUILD_TIME={}", build_time);
    println!("cargo:rustc-env=VERSION={}", version);

    // Also print for debugging
    println!("cargo:warning=Building version: {}", full_version);
}
