Skip to content

Commit

Permalink
Merge pull request #402 from nc7s/reproducible-timestamp
Browse files Browse the repository at this point in the history
Generate man page with reproducible timestamp
  • Loading branch information
ducaale authored Jan 20, 2025
2 parents df9003e + 8d34d5c commit f75d092
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,12 @@ fn generate_manpages(app: &mut clap::Command) {
let mut manpage = MAN_TEMPLATE.to_string();

let current_date = {
let (year, month, day) = DateTime::now_utc().date().to_calendar_date();
// https://reproducible-builds.org/docs/source-date-epoch/
let now = match std::env::var("SOURCE_DATE_EPOCH") {
Ok(val) => DateTime::from_unix_timestamp(val.parse::<i64>().unwrap()).unwrap(),
Err(_) => DateTime::now_utc(),
};
let (year, month, day) = now.date().to_calendar_date();
format!("{}-{:02}-{:02}", year, u8::from(month), day)
};

Expand Down

0 comments on commit f75d092

Please sign in to comment.