static void gen_man(struct lls_parse_result *lpr, const char *cmdline)
{
int i;
- time_t t;
+ time_t t = 0;
struct tm *tmp;
FILE *out;
char *outpath = get_output_path("man",
if (suite.commands[0].name.orig) {
char date[200];
const char *version_string;
-
if (!suite.date) {
- t = time(NULL);
- tmp = localtime(&t);
+ /*
+ * If the SOURCE_DATE_EPOCH environment variable
+ * contains a positive integer in the time_t range, use
+ * that instead of the current time. See:
+ * <https://reproducible-builds.org/specs/source-date-epoch/>
+ * for more information.
+ */
+ char *source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+ if (source_date_epoch != NULL)
+ t = strtoll(source_date_epoch, NULL, 10);
+ if (t <= 0)
+ t = time(NULL);
+ tmp = gmtime(&t);
if (tmp == NULL) {
- perror("localtime");
+ perror("gmtime");
exit(EXIT_FAILURE);
}
if (strftime(date, sizeof(date), "%B %Y", tmp) == 0) {