Skip to content

Commit af0aa5a

Browse files
committed
Allow document revision time to be set from the environment
This can be used to get reproducible HTML output, making it easier to verify that changes to the code do not introduce unwanted changes in the HTML.
1 parent f79c47d commit af0aa5a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/report_generator.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <algorithm>
1212
#include <cassert>
1313
#include <chrono>
14+
#include <cstdlib>
1415
#include <format>
1516
#include <fstream>
1617
#include <memory>
@@ -25,7 +26,15 @@ namespace
2526
// Generic utilities that are useful and do not rely on context or types from our domain (issue-list processing)
2627
// =============================================================================================================
2728

28-
auto const timestamp{std::chrono::floor<std::chrono::seconds>(std::chrono::system_clock::now())};
29+
auto const timestamp = [] {
30+
// Allow the timestamp to be set from a unix timestamp in the environment,
31+
// to support reproducible HTML output. For example:
32+
// LWG_REVISION_TIME=$(date +%s -d "2025-10-07 at 09:38:29 UTC") make lists
33+
if (const char* revtime = std::getenv("LWG_REVISION_TIME"))
34+
return std::chrono::sys_seconds(std::chrono::seconds(std::stol(revtime)));
35+
auto now = std::chrono::system_clock::now();
36+
return std::chrono::floor<std::chrono::seconds>(now);
37+
}();
2938

3039
// global data - would like to do something about that.
3140
std::string const build_date{std::format("{:%F}", timestamp)};

0 commit comments

Comments
 (0)