X-Git-Url: http://git.tuebingen.mpg.de/?p=lopsub.git;a=blobdiff_plain;f=lsg.c;h=83a72da5b3b26b949a09f83d251086fed5a9e02d;hp=54b7816eae94fa99e4b145706403a6d7823abf99;hb=HEAD;hpb=9d3fd447f36e1a144a40037d559a92562d120703 diff --git a/lsg.c b/lsg.c index 54b7816..83a72da 100644 --- a/lsg.c +++ b/lsg.c @@ -610,7 +610,7 @@ static char *get_output_path(const char *suffix, const char *arg, 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", @@ -626,12 +626,22 @@ 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); + /* + * If the SOURCE_DATE_EPOCH environment variable + * contains a positive integer in the time_t range, use + * that instead of the current time. See: + * + * 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) {