mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-22 13:22:28 +00:00
54a7a5069c
to make builds reproducible. See https://reproducible-builds.org/ for why this is good and https://reproducible-builds.org/specs/source-date-epoch/ for the definition of this variable. Also use UTC to be independent of timezone.
15 lines
405 B
Rust
15 lines
405 B
Rust
use chrono::{TimeZone, Utc};
|
|
use std::env;
|
|
|
|
fn main() {
|
|
// Add current date as a variable to be displayed in the 'Linux Toolbox' text.
|
|
let now = match env::var("SOURCE_DATE_EPOCH") {
|
|
Ok(val) => { Utc.timestamp_opt(val.parse::<i64>().unwrap(), 0).unwrap() }
|
|
Err(_) => Utc::now(),
|
|
};
|
|
println!(
|
|
"cargo:rustc-env=BUILD_DATE={}",
|
|
now.format("%Y-%m-%d")
|
|
);
|
|
}
|