diff --git a/lsg.c b/lsg.c index 54b7816..bbad187 100644 --- a/lsg.c +++ b/lsg.c @@ -626,12 +626,19 @@ static void gen_man(struct lls_parse_result *lpr, const char *cmdline) if (suite.commands[0].name.orig) { char date[200]; const char *version_string; - if (!suite.date) { - t = time(NULL); - tmp = localtime(&t); + /* Assume that the SOURCE_DATE_EPOCH environment + * variable will contan a correct, positive integer in + * the time_t range. See: + * + * for more information */ + char *source_date_epoch; + if ((source_date_epoch = getenv("SOURCE_DATE_EPOCH")) == NULL || + (t = (time_t)strtoll(source_date_epoch, NULL, 10)) <= 0) + time(&t); + tmp = gmtime(&t); if (tmp == NULL) { - perror("localtime"); + perror("gmtime"); exit(EXIT_FAILURE); } if (strftime(date, sizeof(date), "%B %Y", tmp) == 0) {