Files
trx-rs/src/trx-server/build.rs
T
sjg 1d0db79ca3 [feat](trx-rs): show server/client build info in HTTP footer
Add compile-time build dates for trx-server and trx-frontend-http, propagate server build metadata through rig state/snapshot, and render both versions + build dates in the HTTP footer.

Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: Stanislaw Grams <stanislawgrams@gmail.com>
2026-02-13 11:06:13 +01:00

26 lines
894 B
Rust

use std::time::{SystemTime, UNIX_EPOCH};
fn utc_ymd_from_unix_secs(secs: i64) -> (i32, u32, u32) {
let days = secs.div_euclid(86_400);
let z = days + 719_468;
let era = if z >= 0 { z } else { z - 146_096 } / 146_097;
let doe = z - era * 146_097;
let yoe = (doe - doe / 1_460 + doe / 36_524 - doe / 146_096) / 365;
let mut y = yoe + era * 400;
let doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
let mp = (5 * doy + 2) / 153;
let d = doy - (153 * mp + 2) / 5 + 1;
let m = mp + if mp < 10 { 3 } else { -9 };
y += if m <= 2 { 1 } else { 0 };
(y as i32, m as u32, d as u32)
}
fn main() {
let secs = match SystemTime::now().duration_since(UNIX_EPOCH) {
Ok(d) => d.as_secs() as i64,
Err(_) => 0,
};
let (y, m, d) = utc_ymd_from_unix_secs(secs);
println!("cargo:rustc-env=TRX_SERVER_BUILD_DATE={y:04}-{m:02}-{d:02}");
}